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 SearchAssembly (System.Reflection.Assembly asm)
 Searches the given assembly for PowerUI modules, custom tags, properties etc. Just an alias for Modular.Start.Now(asm). 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 (string group, GroupResolveEvent 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 Dom when the language of the UI changes. This changes the language of all on screen . UI.Language. More...
 
static void OnVariableChange (string code)
 
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 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 Major =2
 The major version number of PowerUI. More...
 
const int Minor =0
 The minor version number of PowerUI. More...
 
const int Revision =640
 The revision number. More...
 
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 HtmlElement 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 HtmlDocument document
 The main UI document. This is what you should use to add content to the UI. 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 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 string UserAgent [get]
 The user agent that PowerUI uses. More...
 
static string Version [get]
 The version of PowerUI. More...
 
static Window window [get]
 A shortcut to UI.document.window. This is the DOM window API. More...
 
static EventTarget Unhandled [get]
 Clicks, taps and keypresses that pass through the UI and don't hit any WorldUI's will end up being received here. Note that PowerUI already does raycasting so use the MouseEvent.rayHit property. More...
 
static CameraMode CameraMode [get, set]
 What sort of camera should PowerUI use to render the main UI? Perspective is the default. More...
 
static Css.RenderMode RenderMode [get, set]
 How the main UI renders images; either on an atlas or with them 'as is'. Default is Atlas. More...
 
static FilterMode FilterMode [get, set]
 The image filter mode. More...
 
static bool Started [get]
 Has PowerUI started up? 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...
 
static bool IsRedrawUpdate [get]
 The latest real time since startup. Used to make sure PowerUI keeps going when the game is 'paused'. More...
 
static float CurrentFrameTime [get]
 Used in callbacks and OnUpdate; the current redraw frame time. 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 void LanguageChanged (bool goesLeftwards, HtmlDocument htmlDocument)
 Makes sure the default text direction is as given for the given html document. More...
 
static void ResolveVariable (HtmlDocument 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 (HtmlDocument 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 CameraMode CurrentCameraMode =CameraMode.Orthographic
 The current camera mode PowerUI is using. The default is Orthographic. See UI.CameraMode to change this. More...
 

Member Function Documentation

static void PowerUI.UI.CameraGotCreated ( Camera  camera)
inlinestatic

Used internally to fire the OnCameraCreated event.

static void PowerUI.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 PowerUI.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 float PowerUI.UI.GetCameraDistance ( )
inlinestatic

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

static float PowerUI.UI.GetFieldOfView ( )
inlinestatic

Gets the field of view of the UI camera.

static Renderman PowerUI.UI.GetRenderer ( )
inlinestatic

Gets the renderer which renders this UI.

static void PowerUI.UI.HideFromCamera ( Camera  camera)
inlinestatic

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

static void PowerUI.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 void PowerUI.UI.LanguageChanged ( bool  goesLeftwards,
HtmlDocument  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.
static string PowerUI.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 void PowerUI.UI.OnLanguageChange ( string  code)
inlinestatic

Called by Dom 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 PowerUI.UI.OnLogMessage ( string  message)
inlinestatic

Called by wrench when it logs a message.

Parameters
messageThe message to log.
static void PowerUI.UI.OnVariableChange ( string  code)
inlinestatic
static void PowerUI.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 PowerUI.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 PowerUI.UI.RequestFullLayout ( )
inlinestatic

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

static void PowerUI.UI.RequestLayout ( )
inlinestatic

Asks the renderer for a layout (Used internally).

static void PowerUI.UI.ResolveAllVariables ( )
inlinestaticprivate

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

static void PowerUI.UI.ResolveAllVariables ( HtmlDocument  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 PowerUI.UI.ResolveVariable ( HtmlDocument  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 PowerUI.UI.SearchAssembly ( System.Reflection.Assembly  asm)
inlinestatic

Searches the given assembly for PowerUI modules, custom tags, properties etc. Just an alias for Modular.Start.Now(asm).

static void PowerUI.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 PowerUI.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 PowerUI.UI.SetFieldOfView ( float  fov)
inlinestatic

Sets the field of view of the UI camera.

Parameters
fovThe field of view, in degrees.
static void PowerUI.UI.SetGroupResolver ( string  group,
GroupResolveEvent  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 PowerUI.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 PowerUI.UI.Start ( )
inlinestatic

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

static void PowerUI.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.

Member Data Documentation

bool PowerUI.UI._Started
staticprivate

True if Start has been called.

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

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

int PowerUI.UI.CameraDepth =100
static

The default depth of the main camera.

float PowerUI.UI.CameraDistance
static

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

GameObject PowerUI.UI.CameraNode
static

The gameobject that our UI.GUICamera is parented to.

Transform PowerUI.UI.CameraTransform
static

The transform of the UI.GUICamera.

HtmlElement PowerUI.UI.content
static

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

CameraMode PowerUI.UI.CurrentCameraMode =CameraMode.Orthographic
staticprivate

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

const int PowerUI.UI.DefaultRate =40

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

HtmlDocument PowerUI.UI.document
static

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

float PowerUI.UI.FieldOfView
staticprivate

The field of view of the perspective UI camera.

WorldUI PowerUI.UI.FirstWorldUI
static

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

StandardUpdater PowerUI.UI.GlobalUpdater
staticprivate

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

Camera PowerUI.UI.GUICamera
static

The unity camera that will render all UI elements.

GameObject PowerUI.UI.GUINode
static

The gameobject which all UI elements are parented to.

WorldUI PowerUI.UI.LastWorldUI
static

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

int PowerUI.UI.Layer
static

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

const int PowerUI.UI.Major =2

The major version number of PowerUI.

const int PowerUI.UI.Minor =0

The minor version number of PowerUI.

GetSecurityDomain PowerUI.UI.OnGetSecurityDomain
static

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

float PowerUI.UI.RedrawRate
static

The time in seconds between redraws. UI.SetRate.

float PowerUI.UI.RedrawTimer
staticprivate

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

Renderman PowerUI.UI.Renderer
staticprivate

The renderer which renders the main UI.

const int PowerUI.UI.Revision =640

The revision number.

FullVariableSet PowerUI.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 PowerUI.UI.CameraMode
staticgetset

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

float PowerUI.UI.CurrentFrameTime
staticget

Used in callbacks and OnUpdate; the current redraw frame time.

NitroDomainManager PowerUI.UI.DefaultSecurityDomain
staticget

Gets the default security domain for Nitro scripts.

FilterMode PowerUI.UI.FilterMode
staticgetset

The image filter mode.

string PowerUI.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 PowerUI.UI.Html
staticgetset

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

string PowerUI.UI.innerHTML
staticgetset

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

bool PowerUI.UI.IsRedrawUpdate
staticget

The latest real time since startup. Used to make sure PowerUI keeps going when the game is 'paused'.

True if this update is a redraw one. Available from callbacks and OnUpdate.

string PowerUI.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 PowerUI.UI.Log
staticgetset

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

Css.RenderMode PowerUI.UI.RenderMode
staticgetset

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

bool PowerUI.UI.Started
staticget

Has PowerUI started up?

EventTarget PowerUI.UI.Unhandled
staticget

Clicks, taps and keypresses that pass through the UI and don't hit any WorldUI's will end up being received here. Note that PowerUI already does raycasting so use the MouseEvent.rayHit property.

string PowerUI.UI.UserAgent
staticget

The user agent that PowerUI uses.

string PowerUI.UI.Version
staticget

The version of PowerUI.

Window PowerUI.UI.window
staticget

A shortcut to UI.document.window. This is the DOM window API.

Event Documentation

CameraCreated PowerUI.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.