Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 1.54 KB

README.md

File metadata and controls

52 lines (42 loc) · 1.54 KB

UMVC

=== MVC Pattern Framework for Unity3d GUI System

Diagram

Model

  • Holds no view data nor view state data.
  • Is accessed by the Controller and other Models only
  • Will trigger events to notify external system of changes.

View

  • UGUI Prefabs

Presenter

  • Each Presenter corresponds to a View
  • Holds references to elements needed for drawing
  • Receive User Input
  • Notify Controller when an user input
  • This script is a UI refresh operation function set

Controller

  • Controls view flow.
  • Holds the application state needed for that view
  • Will trigger events to notify external system of changes.
  • Handles events either triggered by the player in the View or triggered by the Models
  • Each Controller corresponds to a Presenter and holds the reference of it's Presenter  
  • Holds the references of the small Controllers under this controller

NotificationCenter

  • A notification dispatch mechanism that enables the broadcast of information to registered observers.
  • Add observer in Controllers
  • Post notifications in Models
    void Start()
    {
        NotificationCenter.DefaultCenter.AddObserver(this, "UserDataChanged", UserDataChanged);
    }
    void OnDestroy()
    {
        NotificationCenter.DefaultCenter.RemoveObserver(this, "UserDataChanged");
    }

Create Controller and Presenter from Template

  • Click menu Template Scripts and Create
  • Type class name and namespace
  • Then it will create two scripts, one Controller and one Presenter Diagram