-
Notifications
You must be signed in to change notification settings - Fork 1
View
Feynmen edited this page Jun 18, 2018
·
2 revisions
In your scene, you can create View to help work with components. For example, you have the main menu with 2 pages (Menu and Setting Menu). You can create Controller and 2 Views (MenuView and SettingView). MenuView will be added to Parent Game Object of Menu Panel and SettingView to Setting Panel. Views will contain UI items from panels and implement initialization and access to UI items. You must invoke Init function of View manually, in Controller's Init function
For cleaning data, you can override function Release, which will be invoked when a component Destroying
public override void Release()
{
//Remove some data
}View
public class ButtonView : ViewBase
{
[SerializeField] private Button _button;
public override void Init() { }
public void AddButtonOnClickListener(UnityAction action)
{
_button.onClick.AddListener(action);
}
}Controller
public class TestController : ControllerBase
{
[SerializeField] private ButtonView _buttonView;
protected override void Init()
{
_buttonView.Init();
_buttonView.AddButtonOnClickListener(() =>
{
Disable();
SceneController.Enable<AnotherTestController>();
});
}
}