Detailed Description

This class holds global variables and methods for managing PowerUI. The most important ones are: UI.Start UI.Update UI.document

Static Public Member Functions

static string LoadHTML (string resource)
 Gets the content of the given file from resources. More...
 
static void CameraGotCreated (Camera camera)
 Used internally to fire the OnCameraCreated event. More...
 
static void Start ()
 Startup the UI. Now called internally, but can be called at the start of any scene using PowerUI. More...
 
static void Start (bool nitroAot)
 Used internally - don't call this one. Startup the UI for use in the Editor with AOT Nitro. More...
 
static void HideFromCamera (Camera camera)
 Used to hide the UI from the given camera if it's generated entirely at runtime. More...
 
static void SetDepthResolution (float gaps)
 Sets how many world units are used between elements at different depths. Default is 0.05. More...
 
static Renderman GetRenderer ()
 Gets the renderer which renders this UI. More...
 
static void OnLogMessage (string message)
 Called by wrench when it logs a message. More...
 
static void SetGroupResolver (GroupResolve resolver)
 Sets the group resolver to use when resolving a group name from a variable that isn't found in the languages groups. E.g. &cdn.text; can be handled in custom ways here. More...
 
static void SetCameraDistance (float distance)
 Sets the distance of the camera, essentially defining the amount of z-index available. More...
 
static float GetCameraDistance ()
 Gets the distance of the main UI camera. Essentially defines how much z-index space it has. More...
 
static void SetFieldOfView (float fov)
 Sets the field of view of the UI camera. More...
 
static float GetFieldOfView ()
 Gets the field of view of the UI camera. More...
 
static void ClearAll ()
 Clears all content from the UI and all WorldUI's. Please note that it is safer to set innerHTML to a blank string for a particular UI than calling this. More...
 
static void Destroy ()
 Clears and entirely destroys the UI and WorldUI's. Calling this is not a requirement and can only be reversed by calling Start again. More...
 
static void OnLanguageChange (string code)
 Called by Wrench when the language of the UI changes. This changes the language of all on screen . UI.Language. More...
 
static void AddTextGroup (string text, string groupName)
 Adds a group of variables from the given xml string. Used to stream in languages at runtime. A group is used with &groupName.varName; More...
 
static void OnVariableChange (string code)
 
static LanguageSet[] GetAllLanguages ()
 Gets a list of all available languages for use with the UI. More...
 
static void RequestLayout ()
 Asks the renderer for a layout (Used internally). More...
 
static void SetRate (int fps)
 Sets the update rate of the UI. More...
 
static bool MouseOver (float x, float y)
 Returns true if the given x/y coordinate is over the UI. More...
 
static bool HandleInput ()
 Handles mouse and keyboard input. Call this from OnGUI. More...
 
static bool InternalHandleInput ()
 Handles mouse and keyboard input. Called from OnGUI internally. See HandleInput. More...
 
static void RedrawNextUpdate ()
 Prompts the UI to redraw on the next Update. You don't need to call this, however it can be useful in rare situations where you require the UI to bypass it's usual redraw rate (see SetRate) and refresh immediately. More...
 
static void RedrawNow ()
 In general you should never call this. It forces a full Update to occur right now; this can only be called from the main Unity thread. More...
 
static void RequestFullLayout ()
 Requests all UI's to update. This occurs when an atlas has been optimised. More...
 
static void InternalUpdate ()
 Updates the UI. Don't call this - PowerUI knows when it's needed; This is done from Start and WorldUI constructors. More...
 

Public Attributes

const int DefaultRate =40
 The default max update rate in fps. Note that input is decoupled from this. More...
 

Static Public Attributes

static int Layer
 The PowerUI layer's index. Used to make sure the UI is not visible with other cameras. More...
 
static Element content
 A custom content element. You can set this to whatever element you want for easy access. More...
 
static float RedrawRate
 The time in seconds between redraws. UI.SetRate. More...
 
static Camera GUICamera
 The unity camera that will render all UI elements. More...
 
static Document document
 The main UI document. This is what you should use to add content to the UI. More...
 
static bool HandledInput
 True if the UI consumed the current frames input event. More...
 
static GameObject GUINode
 The gameobject which all UI elements are parented to. More...
 
static float CameraDistance
 How much space should be given for elements. This distance essentially defines how much z-index is allowed. More...
 
static GameObject CameraNode
 The gameobject that our UI.GUICamera is parented to. More...
 
static Transform CameraTransform
 The transform of the UI.GUICamera. More...
 
static FullVariableSet Variables
 This variable set is used when parsing the HTML. can be used to replace text with custom values; e.g. in localization or . More...
 
static WorldUI LastWorldUI
 All world UI's are kept in a linked list for updates. This is the tail of the list. More...
 
static WorldUI FirstWorldUI
 All world UI's are kept in a linked list for updates. This is the head of the list. More...
 
static int CameraDepth =100
 The default depth of the main camera. More...
 
static CameraPool MainCameraPool
 A set of cameras available for use with the main UI. This is only ever used with inline cameras. More...
 
static Type BaseCodeType =typeof(UICode)
 The type that all code derives from. Must be UICode or something that inherits UICode. More...
 
static GetSecurityDomain OnGetSecurityDomain
 Called when a document wants the default security domain. Set with a custom method to provide your own. More...
 
static int AtlasSize
 

Properties

static ResolutionInfo Resolution [get, set]
 The current UI resolution, used for pixel perfect clarity if you target both high and low resolution screens. Note that this should only be changed before you apply any HTML to your UI's. More...
 
static CameraMode CameraMode [get, set]
 What sort of camera should PowerUI use to render the main UI? Perspective is the default. More...
 
static RenderMode RenderMode [get, set]
 How the main UI renders images; either on an atlas or with them 'as is'. Default is Atlas. More...
 
static InputMode InputMode [get, set]
 The mode PowerUI uses for recieving input. Physics mode is more intensive than Screen mode, however using physics mode means transformed elements receive input correctly. More...
 
static InputMode WorldInputMode [get, set]
 The mode PowerUI uses for recieving input for WorldUI's. Physics mode is more intensive than Screen mode, however using physics mode means transformed elements receive input correctly. None by default. More...
 
static FilterMode FilterMode [get, set]
 The image filter mode. More...
 
static FilterMode TextFilterMode [get, set]
 Sets the text filter mode. Note: shared fonts will be affected in all other UI's. More...
 
static string Language [get, set]
 Gets or sets the language code (e.g. "en") of the UI. This will internally update any onscreen variables for localization so you won't need to restart the game. Please refer to our guides on localization on the website for further help with this. More...
 
static string Gender [get, set]
 Gets or sets the gender (boy, girl, either). This is used for localization where some text is better off being specific depending on what gender the player is - e.g. when using she/ he. More...
 
static NitroDomainManager DefaultSecurityDomain [get]
 Gets the default security domain for Nitro scripts. More...
 
static bool Log [get, set]
 Gets/sets if the UI should log messages to the console. Default is true. More...
 
static string Html [get, set]
 Shortcut for calling UI.Start then using UI.document.innerHTML. Applies the given HTML to the whole main UI. More...
 
static string innerHTML [get, set]
 Shortcut for calling UI.Start then using UI.document.innerHTML. Applies the given HTML to the whole main UI. More...
 

Events

static CameraCreated OnCameraCreated
 This event is fired when PowerUI generates a new camera. This is the best way to apply custom rendering to the main UI. More...
 

Static Private Member Functions

static Wrench.UnityLanguageLoader GetLanguageLoader ()
 Gets a loader which tells the wrench framework where to look for language specific UI text ( content). This is set to Resources/Languages/UI. More...
 
static void UpdateTextDirection ()
 Makes sure the default text direction matches the one given by the language (e.g. Arabic may tell PowerUI it goes leftwards). Applies to the main UI and all in-world UI's. More...
 
static void UpdateTextDirection (bool goesLeftwards, Document htmlDocument)
 Makes sure the default text direction is as given for the given html document. More...
 
static void ResolveVariable (Document htmlDocument, string code)
 Resolves all as used by the given document their new values. Used when e.g. the language changes. More...
 
static void ResolveAllVariables ()
 Resolves all as used by PowerUI to their new values. Used when e.g. the language changes. More...
 
static void ResolveAllVariables (Document htmlDocument)
 Resolves all as used by the given document their new values. Used when e.g. the language changes. More...
 

Static Private Attributes

static bool Started
 True if Start has been called. More...
 
static float FieldOfView
 The field of view of the perspective UI camera. More...
 
static float RedrawTimer
 How much time, in seconds, has passed since our last redraw. More...
 
static Renderman Renderer
 The renderer which renders the main UI. More...
 
static StandardUpdater GlobalUpdater
 Updates the UI globally. Note that this is setup automatically for you. More...
 
static UnityLanguageLoader LanguageLoader
 A loader which pulls languages from the Resources/Languages/UI folder. More...
 
static CameraMode CurrentCameraMode =CameraMode.Perspective
 The current camera mode PowerUI is using. The default is Perspective. See UI.CameraMode to change this. More...
 

Member Function Documentation

static void UI.AddTextGroup ( string  text,
string  groupName 
)
inlinestatic

Adds a group of variables from the given xml string. Used to stream in languages at runtime. A group is used with &groupName.varName;

static void UI.CameraGotCreated ( Camera  camera)
inlinestatic

Used internally to fire the OnCameraCreated event.

static void UI.ClearAll ( )
inlinestatic

Clears all content from the UI and all WorldUI's. Please note that it is safer to set innerHTML to a blank string for a particular UI than calling this.

static void UI.Destroy ( )
inlinestatic

Clears and entirely destroys the UI and WorldUI's. Calling this is not a requirement and can only be reversed by calling Start again.

static LanguageSet [] UI.GetAllLanguages ( )
inlinestatic

Gets a list of all available languages for use with the UI.

Returns
A list of variable sets. Each one represents a UI language.
static float UI.GetCameraDistance ( )
inlinestatic

Gets the distance of the main UI camera. Essentially defines how much z-index space it has.

static float UI.GetFieldOfView ( )
inlinestatic

Gets the field of view of the UI camera.

static Wrench.UnityLanguageLoader UI.GetLanguageLoader ( )
inlinestaticprivate

Gets a loader which tells the wrench framework where to look for language specific UI text ( content). This is set to Resources/Languages/UI.

static Renderman UI.GetRenderer ( )
inlinestatic

Gets the renderer which renders this UI.

static bool UI.HandleInput ( )
inlinestatic

Handles mouse and keyboard input. Call this from OnGUI.

Returns
True if the UI consumed the current event.
static void UI.HideFromCamera ( Camera  camera)
inlinestatic

Used to hide the UI from the given camera if it's generated entirely at runtime.

static bool UI.InternalHandleInput ( )
inlinestatic

Handles mouse and keyboard input. Called from OnGUI internally. See HandleInput.

Returns
True if the UI consumed the current event.
static void UI.InternalUpdate ( )
inlinestatic

Updates the UI. Don't call this - PowerUI knows when it's needed; This is done from Start and WorldUI constructors.

static string UI.LoadHTML ( string  resource)
inlinestatic

Gets the content of the given file from resources.

Parameters
resourceThe path to the file in Resources.
Returns
The file content which should be html formatted.
static bool UI.MouseOver ( float  x,
float  y 
)
inlinestatic

Returns true if the given x/y coordinate is over the UI.

Parameters
xThe on screen x coordinate as measured from the left.
yThe on screen y coordinate as measured from the top.
Returns
True if the mouse is over an element.
static void UI.OnLanguageChange ( string  code)
inlinestatic

Called by Wrench when the language of the UI changes. This changes the language of all on screen . UI.Language.

Parameters
codeThe language code/id (e.g. en).
static void UI.OnLogMessage ( string  message)
inlinestatic

Called by wrench when it logs a message.

Parameters
messageThe message to log.
static void UI.OnVariableChange ( string  code)
inlinestatic
static void UI.RedrawNextUpdate ( )
inlinestatic

Prompts the UI to redraw on the next Update. You don't need to call this, however it can be useful in rare situations where you require the UI to bypass it's usual redraw rate (see SetRate) and refresh immediately.

static void UI.RedrawNow ( )
inlinestatic

In general you should never call this. It forces a full Update to occur right now; this can only be called from the main Unity thread.

static void UI.RequestFullLayout ( )
inlinestatic

Requests all UI's to update. This occurs when an atlas has been optimised.

static void UI.RequestLayout ( )
inlinestatic

Asks the renderer for a layout (Used internally).

static void UI.ResolveAllVariables ( )
inlinestaticprivate

Resolves all as used by PowerUI to their new values. Used when e.g. the language changes.

static void UI.ResolveAllVariables ( Document  htmlDocument)
inlinestaticprivate

Resolves all as used by the given document their new values. Used when e.g. the language changes.

Parameters
htmlDocumentThe document to update the variables for.
static void UI.ResolveVariable ( Document  htmlDocument,
string  code 
)
inlinestaticprivate

Resolves all as used by the given document their new values. Used when e.g. the language changes.

Parameters
htmlDocumentThe document to update the variables for.
static void UI.SetCameraDistance ( float  distance)
inlinestatic

Sets the distance of the camera, essentially defining the amount of z-index available.

Parameters
distanceThe distance of the camera from the origin along the z axis in world units.
static void UI.SetDepthResolution ( float  gaps)
inlinestatic

Sets how many world units are used between elements at different depths. Default is 0.05.

Parameters
gapsThe distance between elements to use.
static void UI.SetFieldOfView ( float  fov)
inlinestatic

Sets the field of view of the UI camera.

Parameters
fovThe field of view, in degrees.
static void UI.SetGroupResolver ( GroupResolve  resolver)
inlinestatic

Sets the group resolver to use when resolving a group name from a variable that isn't found in the languages groups. E.g. &cdn.text; can be handled in custom ways here.

Parameters
resolverThe resolver to use.
static void UI.SetRate ( int  fps)
inlinestatic

Sets the update rate of the UI.

Parameters
fpsThe rate in frames per second. Default is UI.DefaultRate.
static void UI.Start ( )
inlinestatic

Startup the UI. Now called internally, but can be called at the start of any scene using PowerUI.

static void UI.Start ( bool  nitroAot)
inlinestatic

Used internally - don't call this one. Startup the UI for use in the Editor with AOT Nitro.

Parameters
nitroAotTrue if no gameobject should be generated.
static void UI.UpdateTextDirection ( )
inlinestaticprivate

Makes sure the default text direction matches the one given by the language (e.g. Arabic may tell PowerUI it goes leftwards). Applies to the main UI and all in-world UI's.

static void UI.UpdateTextDirection ( bool  goesLeftwards,
Document  htmlDocument 
)
inlinestaticprivate

Makes sure the default text direction is as given for the given html document.

Parameters
goesLeftwardsTrue if the default text direction is leftwards.
htmlDocumentThe document to apply the setting to.

Member Data Documentation

int UI.AtlasSize
static
Type UI.BaseCodeType =typeof(UICode)
static

The type that all code derives from. Must be UICode or something that inherits UICode.

int UI.CameraDepth =100
static

The default depth of the main camera.

float UI.CameraDistance
static

How much space should be given for elements. This distance essentially defines how much z-index is allowed.

GameObject UI.CameraNode
static

The gameobject that our UI.GUICamera is parented to.

Transform UI.CameraTransform
static

The transform of the UI.GUICamera.

Element UI.content
static

A custom content element. You can set this to whatever element you want for easy access.

CameraMode UI.CurrentCameraMode =CameraMode.Perspective
staticprivate

The current camera mode PowerUI is using. The default is Perspective. See UI.CameraMode to change this.

const int UI.DefaultRate =40

The default max update rate in fps. Note that input is decoupled from this.

Document UI.document
static

The main UI document. This is what you should use to add content to the UI.

float UI.FieldOfView
staticprivate

The field of view of the perspective UI camera.

WorldUI UI.FirstWorldUI
static

All world UI's are kept in a linked list for updates. This is the head of the list.

StandardUpdater UI.GlobalUpdater
staticprivate

Updates the UI globally. Note that this is setup automatically for you.

Camera UI.GUICamera
static

The unity camera that will render all UI elements.

GameObject UI.GUINode
static

The gameobject which all UI elements are parented to.

bool UI.HandledInput
static

True if the UI consumed the current frames input event.

UnityLanguageLoader UI.LanguageLoader
staticprivate

A loader which pulls languages from the Resources/Languages/UI folder.

WorldUI UI.LastWorldUI
static

All world UI's are kept in a linked list for updates. This is the tail of the list.

int UI.Layer
static

The PowerUI layer's index. Used to make sure the UI is not visible with other cameras.

CameraPool UI.MainCameraPool
static

A set of cameras available for use with the main UI. This is only ever used with inline cameras.

GetSecurityDomain UI.OnGetSecurityDomain
static

Called when a document wants the default security domain. Set with a custom method to provide your own.

float UI.RedrawRate
static

The time in seconds between redraws. UI.SetRate.

float UI.RedrawTimer
staticprivate

How much time, in seconds, has passed since our last redraw.

Renderman UI.Renderer
staticprivate

The renderer which renders the main UI.

bool UI.Started
staticprivate

True if Start has been called.

FullVariableSet UI.Variables
static

This variable set is used when parsing the HTML. can be used to replace text with custom values; e.g. in localization or .

Property Documentation

CameraMode UI.CameraMode
staticgetset

What sort of camera should PowerUI use to render the main UI? Perspective is the default.

NitroDomainManager UI.DefaultSecurityDomain
staticget

Gets the default security domain for Nitro scripts.

FilterMode UI.FilterMode
staticgetset

The image filter mode.

string UI.Gender
staticgetset

Gets or sets the gender (boy, girl, either). This is used for localization where some text is better off being specific depending on what gender the player is - e.g. when using she/ he.

string UI.Html
staticgetset

Shortcut for calling UI.Start then using UI.document.innerHTML. Applies the given HTML to the whole main UI.

string UI.innerHTML
staticgetset

Shortcut for calling UI.Start then using UI.document.innerHTML. Applies the given HTML to the whole main UI.

InputMode UI.InputMode
staticgetset

The mode PowerUI uses for recieving input. Physics mode is more intensive than Screen mode, however using physics mode means transformed elements receive input correctly.

string UI.Language
staticgetset

Gets or sets the language code (e.g. "en") of the UI. This will internally update any onscreen variables for localization so you won't need to restart the game. Please refer to our guides on localization on the website for further help with this.

bool UI.Log
staticgetset

Gets/sets if the UI should log messages to the console. Default is true.

RenderMode UI.RenderMode
staticgetset

How the main UI renders images; either on an atlas or with them 'as is'. Default is Atlas.

ResolutionInfo UI.Resolution
staticgetset

The current UI resolution, used for pixel perfect clarity if you target both high and low resolution screens. Note that this should only be changed before you apply any HTML to your UI's.

FilterMode UI.TextFilterMode
staticgetset

Sets the text filter mode. Note: shared fonts will be affected in all other UI's.

InputMode UI.WorldInputMode
staticgetset

The mode PowerUI uses for recieving input for WorldUI's. Physics mode is more intensive than Screen mode, however using physics mode means transformed elements receive input correctly. None by default.

Event Documentation

CameraCreated UI.OnCameraCreated
static

This event is fired when PowerUI generates a new camera. This is the best way to apply custom rendering to the main UI.