UI Module

UI modules manages everything related to user interface and its interaction.

Main Elements

UI module consists of two parts : View and Menu

View

View handles UI displays and receives user inputs

  • Data for Views are injected from Menu, and the data should not be modified

  • View must not modify data, except for display purposes (displaying progress bar, etc.)

  • Views are modified either by data-binding or manually called by the Menu.

  • Menu is the "gateway" between View and Systems.

  • Menu listens to events from View and perform data modification by calling Systems.

  • Menu is the place to handle the logic of data manipulation.

    • For example, Menu can listen to "upgrade button" event from view.

    • As a result, it can call Uprade.IncrementLevel to increase upgrade level and Inventory.Spend to reduce the coins in inventory.

  • Each window in RR is separated into a Menu prefab, for example ResearchMenu, WardrobeMenu, etc.

  • The name of prefab must match the name of the Menu class.

  • This prefab is placed in Resources folder and can be loaded by calling static method Open() for example ResearchMenu.Open().

  • The prefab also determines its placement in UI Root and its behaviour.

UI Root

UI Root is a "singleton" prefab. for UI Canvas, Event Systems, and UI Camera. All UI items must be placed inside UI Root.

Testing View

  • It is advisable to have a separate scene to test View functionality

  • In the Test Scene, use a self-contained data that can be injected directly into View

  • See some existing test scene as reference.

Last updated