Getting Start(toturial)

HnMVC architecture

1.Create Contex

  • Create a new empty gameobject and add a c# script component.

  • Create a contex class drive from class "HnFramework.MVC.Contex", e.g. "XXContex".

  • Override function "InitCommand".

2.Create Command

  • Create a SceneCommand or StartCommand class drive from class "HnFramework.MVC.Command", e.g. "XXCommand".

  • Override function "InitModel".

  • Call function "BindCommand(new XXCommand(this));" in the function "InitCommand" of "XXContex".

  • Create other bussiness Command class drive from class "HnFramework.MVC.Command".

  • Override function "OnStart", and add listener.

3.Create Model

  • Create model class drive from class "HnFramework.MVC.Model", e.g. "XXModel".

  • Call function "BindModel(enum, XXModel.GetSingleton());" in the function "InitModel" of "SceneCommand".

4.Create Mediator

  • Create mediator class drive from class "HnFramework.MVC.Mediator", e.g. "XXMediator".

  • Override function "OnInit", then get view class and add listener.

5.Create View

  • Create view class drive from class "HnFramework.MVC.View", e.g. "XXView" and add the script component to any ui gameobject.

  • Override function "InitMediator", and bind mediator.

6.Dispatch

  • You can call function "DispatchCommand(enum)" to make command work(e.g. get model datas) in view or mediator class.

  • You can call function "DispatchMediator(enum)" to update UI in command class.

Last updated