UI


Game Framework provides many components and classes to help you with working with the Unity UI system and creating great looking interfaces. The below is a description of some of these features.

There is also provided a powerful dialog system for the creation and display of custom dialogs, including several standard dialogs for game over, settings and messaging. See the dialog pages for more information and also the Game Structure pages that cover setup of levels, players and much more.

As an introduction to a number of these concepts we recommend first going through the Getting Started Tutorial.

Working With Buttons

Handling Clicks

The components OnButtonClickExit, OnButtonClickLoadScene and OnButtonClickLoadUrl can be added to any gameobject that has a UI button and will automatically hook up an event to exit, load a new scene or load a url when the button is clicked. Loading of a scene will invoke any transitions if you are using hte Beautiful Transitions component. These components inherit from the The OnButtonClick abstract component that provides most of the functionality for connecting up the button.

Several other feature areas also provide such button click handlers tailored to their specific functionality (such as showing the free prize dialog or settings window). These components are documented separately.

Syncing Button State Changes

More complex buttons might be composed of multiple child images and objects. When added to a gameobject with a UI Button, any implementation of the SyncState abstract component will be automatically notified of state changes so they can react and update the display or otherwise. Implementations of SyncState include:

  • SyncStateImageColors which will update images with different colors based upon the different states
  • SyncStateTextColors which will update text, shadows and outlines with different colors based upon the different states

Counters

<description coming soon>

For not see TimeRemaining component

Animated Value Changes

<description coming soon>

For now see ShowValueAnimated and ShowValueAnimatedMessaging components

Misc

The UIHelper class provides a number of methods for working with UI’s. One of the key areas supported is automatic lookup and manipulation of named gameobjects without the need for complex code and conditional checks such as setting localised text on a named child gameobject (SetTextOnChildGameObjectLocalised())

The GradientText component will allow for adding a gradient to a UI Text element. Just add this to a gameobject that contains an existing UI Text component.

The ScrollRectEnsureVisible component provides methods for scrolling a scrollrect to ensure that a specified item is displayed. This can be useful if you are doing something like unlocking a level and are not sure that the level you are unlocking is actually visible within a scrolling window.

See also

If you have any thoughts or suggestions on improvements or additions to the UI features then please let us know!