Skip to main content
1 of 3
Candid Moon _Max_
  • 2.9k
  • 1
  • 22
  • 39

I have system like OMCV - Object Model Controller View. If this helps you. In Objects I have data objects (models) that are sent to Controller which decides to what view to assign the data. In your case you could have a Controller that has calls to Views and use it by calling methods from controller from Buttons.

But for this purpose I would have different Views that are Models and Controllers of itself.

For example, Confirmation Window - it has a method public void ApplyConfirmation(UnityAction buttonConfirmationAction, string text); - and when you click on exit button wich has some method applied to if from MenuManager or whatever which has a call to Confirmation Window.

ConfirmationWindow.Instance.ApplyConfirmation(delegate { this.ExitGame(this.SaveDataBeforeExit) }, "Do you really want to exit?");

Now confirmation window pops up. ApplyConfirmation in my case has an "Yes" button which is asigned any method to be called when it's pressed and a text that changes the text on pop up window.

If you are sure that you are going to have only 1 UI element of that behavior and you can reuse it - you can go ahead and make it a Singleton to be able to call it easily from any class like UIElementClassName.Instance.PublicMethodToCall();

Hope you got the idea from it.

Candid Moon _Max_
  • 2.9k
  • 1
  • 22
  • 39