Skip to content
Benedikt Hensen edited this page Oct 30, 2018 · 3 revisions

Menus

The menus consist of a visual component and the functional logic. The visual aspects are represented using Unity's game objects and are composed of buttons which are created from the button template.

The logical functionality is implemented in a script which is usually attached to the uppermost game object of the menu.

Structure of the Menu Script

The menus inherit from BaseMenu. This class already implements the basic functionality to react on localization.

Start Method

The menus implement a start method which is automatically called by Unity once the menu is instantiated. Usually, the start method calls the button initalization method.

Button Initalization

Once the menu is instantiated, the menu scripts store references to the menu's button scripts. They are searched by the name of the button's game object and can later be used to manipulate the buttons. Additionally, the buttons OnClick methods are specified in order add functionality to the button. Finally, the language on the buttons is updated.

Language Update

The 3D menus all inherit from a base menu class which implements a language updater interface. Once the menu it created, it registers itself as an update receiver at the localization manager. Whenever the language in the information manager is changed, the localization manager notifies all receivers by calling their OnUpdateLanguage method. Each menu has an individual implementation of this method where the texts for all the menu-specific controls are translated and set. Thus, if the language is changed, all open menus immediately adapt and display the translations of the newly selected language. If a menu is closed, it de-registers itself as an update receiver at the localization manager.

See Also

Clone this wiki locally