Detailed Description

Flat WorldUI's render to textures. Normal worldUI's are better for performance but flat worldUI's are more flexible. Free/Indie users should use normal WorldUI's instead for performance purposes, however this can still be used. The difference here is the texture can be e.g. applied to a curved surface.

Inheritance diagram for PowerUI.FlatWorldUI:
PowerUI.WorldUI

Public Member Functions

 FlatWorldUI ()
 Creates a new Flat World UI with 100x100 pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 FlatWorldUI (string name)
 Creates a new Flat World UI with 100x100 pixels of space and the given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 FlatWorldUI (int widthPX, int heightPX)
 Creates a new Flat World UI with the given pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 FlatWorldUI (string name, int widthPX, int heightPX)
 Creates a new Flat World UI with the given pixels of space and a given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
override void ResolvePoint (RaycastHit hit, out float x, out float y)
 Resolves a hit to a point on this WorldUI. Note that x and y are 'relative' in the -0.5 to +0.5 range. More...
 
void ApplyTo (GameObject gameObject)
 Applies Texture to the sharedMaterial on the gameobject. More...
 
void ApplyTo (Material material)
 Applies Texture to material.mainTexture. More...
 
Material CreateMaterial (Shader shader)
 Creates a material with the given shader and applies texture to its mainTexture property. More...
 
Material CreateMaterial ()
 Creates a Standard Shader material and applies texture to its mainTexture property. More...
 
override void RenderWithCamera (int layer)
 Puts all batches of this renderer into the given unity layer. More...
 
void SetCameraDistance (float distance)
 Sets the distance of the camera, essentially defining the amount of z-index available. More...
 
override void SetOrigin (float x, float y)
 Sets the location of the gameobjects origin relatively. More...
 
override void SetResolution (float pp)
 Sets how many Pixels Per World unit this renderer uses. Maps directly to applying a scale. Default is 100. The actual world space size is dictated by this and PowerUI.WorldUI.SetDimensions. The amount of pixels and pixels per world unit (resolution). More...
 
override void SetResolution (int x, int y)
 Sets how many Pixels Per World unit this renderer uses, allowing for distortion. Maps directly to applying a scale. Default is 100 on each axis. The actual world space size is dictated by this and PowerUI.WorldUI.SetDimensions. The amount of pixels and pixels per world unit (resolution). More...
 
override bool SetDimensions (int x, int y)
 Sets how many pixels of space this renderer has. The actual world space size is dictated by this and PowerUI.WorldUI.SetResolution. The amount of pixels and pixels per world unit (resolution). More...
 
- Public Member Functions inherited from PowerUI.WorldUI
 WorldUI ()
 Creates a new World UI with 100x100 pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 WorldUI (string name)
 Creates a new World UI with 100x100 pixels of space and the given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 WorldUI (int widthPX, int heightPX)
 Creates a new World UI with the given pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
 WorldUI (string name, int widthPX, int heightPX)
 Creates a new World UI with the given pixels of space and a given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution. More...
 
void CameraChanged ()
 Call this if you change the field of view of the camera looking at a pixel perfect WorldUI. More...
 
void UpdateResolution ()
 Flushes resolution changes. Use this after a set resolution method if you want to see your changes on the next update. Note that this is not needed when you've just created your WorldUI or if you're also changing any innerHTML or styles at the same time. Internally this just generates a layout request. More...
 
void SetDepthResolution (float gaps)
 Sets how many world units are used between elements at different depths. Default is 0.01. You'll generally want this to be as small as possible to make the UI appear flat. Too small though and you'll get z-fighting. You can also use large values if you want to achieve a unique effect. More...
 
void SetResolution (int ppw)
 Sets how many Pixels Per World unit this renderer uses. Maps directly to applying a scale. Default is 100. The actual world space size is dictated by this and PowerUI.WorldUI.SetDimensions. The amount of pixels and pixels per world unit (resolution). More...
 
void FaceCamera (Camera cameraToFace)
 Makes this UI always face the given camera. More...
 
void FaceCamera ()
 Makes this UI face the main camera until told to stop. Note that this only needs to be called once. More...
 
void StopFacingCamera ()
 Stops making this UI face a camera. More...
 
void Update ()
 Updates this UI. Called internally by UI.Update. More...
 
void ParentToOrigin (Transform parent)
 Parents this WorldUI to the given gameobject and then moves it to the transforms origin. More...
 
void ParentToOrigin (GameObject parent)
 Parents this WorldUI to the given gameobject and then moves it to the gameobjects origin. More...
 
void GotoLocalOrigin ()
 Moves this world UI so it's at the origin of it's parents transform. More...
 
void Expire ()
 Expires this WorldUI now. More...
 
void CancelExpiry ()
 Cancels a pending expiry. More...
 
void SetExpiry (float expiry)
 Sets an expiry time for this WorldUI. It will be destroyed in this many seconds. More...
 
Vector2 RelativePoint (float x, float y)
 Maps a relative (-0.5 to +0.5) point into the 0-width/height range. Great for use with colliders. More...
 
void Destroy ()
 Destroys this UI. Note that this also occurs if the gameobject is destroyed; Just destroying the gameobject or a parent gameObject is all that is required. More...
 

Public Attributes

Texture Texture
 The raw texture. Note that for Unity Pro users, this is always a RenderTexture (and a Texture2D for free users). More...
 
Camera SourceCamera
 The internal camera being used to render it flat. More...
 
GameObject CameraObject
 The internal camera's gameobject being used. More...
 
- Public Attributes inherited from PowerUI.WorldUI
bool Flat
 True if this UI is rendering flat. More...
 
float Ratio =1f
 The width/height ratio. More...
 
int pixelWidth
 The width of the UI in pixels. More...
 
int pixelHeight
 The height of the UI in pixels. More...
 
HtmlDocument document
 The HTML document for this UI. Use this to edit the content. More...
 
Transform transform
 The world space transform of the UI. Use this to move it around. More...
 
GameObject gameObject
 The game object that this UI is parented to. More...
 
string Name
 The name of this WorldUI. Use WorldUI.Find to obtain a WorldUI by name. More...
 
bool Expires
 Does this WorldUI expire? More...
 
float ExpiresIn
 How long until this worldUI expires. More...
 
WorldUI UIAfter
 For internal use. All WorldUI's are stored as a linked list for updates. This is the next one in the list. More...
 
WorldUI UIBefore
 For internal use. All WorldUI's are stored as a linked list for updates. This is the one before this in the list. More...
 
float PixelHeightF
 The height of the UI in pixels as a float. More...
 
Renderman Renderer
 The renderer that renders this UI. More...
 
Camera CameraToFace
 The camera to look at. Camera.main is used if this is null and AlwaysFaceCamera is true. More...
 
bool AlwaysFaceCamera
 <sumamry>True if this UI should face the main camera. More...
 
WorldUIExpiryEvent OnExpire
 An event called when this WorldUI expires. Returning false prevents the default destroy action. More...
 
Vector2 WorldScreenOrigin =Vector2.zero
 The location of the origin in pixels. Set internally; see PowerUI.WorldUI.SetOrigin. More...
 
Vector2 OriginLocation =new Vector2(0.5f,0.5f)
 The location of the gameobjects origin relatively. Set internally; see PowerUI.WorldUI.SetOrigin. More...
 
int AtlasSize
 

Static Public Attributes

static float GlobalOffset =-150f
 Global position offset. More...
 
- Static Public Attributes inherited from PowerUI.WorldUI
static Dictionary< Transform,
WorldUI
PhysicsLookup
 A lookup used to quickly find a WorldUI from its transform. Used for physics based input resolving. More...
 
static bool LiveUpdatablesAvailable
 True if any of the live WorldUI's are 'updateable'. These are pixel perfect or ones which are facing a camera. More...
 

Properties

Texture texture [get]
 Alias for Texture. More...
 
- Properties inherited from PowerUI.WorldUI
int RenderQueue [get, set]
 The render queue that this worldUI is in. More...
 
bool PixelPerfect [get, set]
 True if the resolution of this WorldUI is automatically updated such that the UI is always pixel perfect. More...
 
Css.RenderMode RenderMode [get, set]
 How this WorldUI renders images; either on an atlas or with them 'as is'. Default is Atlas. More...
 
int Layer [get, set]
 The layer to put this worldUI in. More...
 
Transform PhysicsModeCollider [get]
 The collider's transform if WorldUI's are in Screen input mode. This will have a BoxCollider attached. More...
 
Vector2 WorldPerPixel [get]
 The amount of world units per pixel. This is just the transform scale. More...
 
Vector2 WorldScreenSize [get]
 The size of the screen in world units. More...
 
bool AcceptInput [get, set]
 True if this WorldUI accepts input. It's false by default. More...
 

Private Member Functions

void SetOrthographicSize ()
 

Private Attributes

int DefaultLayer =-1
 The default layer to use for rendering FlatWorldUI's. If not set the PowerUI layer is used, Change by using yourWorldUI.Layer. More...
 
FlatWorldUIHandler Handler
 A handler which ensures the camera remains the right size. More...
 
bool RequiresOffset
 Flat world UI's get stacked up on top of each other in virtual space. This is true if it will update the offset of one UI to another when SetDimensions is called. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PowerUI.WorldUI
static void UpdateAll ()
 Updates all worldUI's. Called internally to update pixel perfect WorldUI's. More...
 
static WorldUI Find (RaycastHit hit)
 Checks if the given hit was on a WorldUI. If it was, it returns the WorldUI that was hit. More...
 
static WorldUI Find (Transform transform)
 Finds a WorldUI instance for the given transform. More...
 
static WorldUI Find (string name)
 Finds a WorldUI by name. Note that this is a linear scan so it's very wise to keep hold of references to your WorldUI's where possible. If multiple WorldUI's have the same name, the latest one created is returned. More...
 

Constructor & Destructor Documentation

PowerUI.FlatWorldUI.FlatWorldUI ( )
inline

Creates a new Flat World UI with 100x100 pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution.

PowerUI.FlatWorldUI.FlatWorldUI ( string  name)
inline

Creates a new Flat World UI with 100x100 pixels of space and the given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution.

Parameters
nameThe name for the UI's gameobject.
PowerUI.FlatWorldUI.FlatWorldUI ( int  widthPX,
int  heightPX 
)
inline

Creates a new Flat World UI with the given pixels of space and a name of "new World UI". The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution.

Parameters
widthPXThe width in pixels of this UI.
heightPXThe height in pixels of this UI.
PowerUI.FlatWorldUI.FlatWorldUI ( string  name,
int  widthPX,
int  heightPX 
)
inline

Creates a new Flat World UI with the given pixels of space and a given name. The gameobjects origin sits at the middle of the UI by default. See PowerUI.WorldUI.SetOrigin. By default, 100 pixels are 1 world unit. See PowerUI.WorldUI.SetResolution.

Parameters
nameThe name for the UI's gameobject.
widthPXThe width in pixels of this UI.
heightPXThe height in pixels of this UI.

Member Function Documentation

void PowerUI.FlatWorldUI.ApplyTo ( GameObject  gameObject)
inline

Applies Texture to the sharedMaterial on the gameobject.

void PowerUI.FlatWorldUI.ApplyTo ( Material  material)
inline

Applies Texture to material.mainTexture.

Material PowerUI.FlatWorldUI.CreateMaterial ( Shader  shader)
inline

Creates a material with the given shader and applies texture to its mainTexture property.

Material PowerUI.FlatWorldUI.CreateMaterial ( )
inline

Creates a Standard Shader material and applies texture to its mainTexture property.

override void PowerUI.FlatWorldUI.RenderWithCamera ( int  id)
inlinevirtual

Puts all batches of this renderer into the given unity layer.

Parameters
idThe ID of the unity layer.

Reimplemented from PowerUI.WorldUI.

override void PowerUI.FlatWorldUI.ResolvePoint ( RaycastHit  hit,
out float  x,
out float  y 
)
inlinevirtual

Resolves a hit to a point on this WorldUI. Note that x and y are 'relative' in the -0.5 to +0.5 range.

Reimplemented from PowerUI.WorldUI.

void PowerUI.FlatWorldUI.SetCameraDistance ( float  distance)
inline

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.
override bool PowerUI.FlatWorldUI.SetDimensions ( int  widthPX,
int  heightPX 
)
inlinevirtual

Sets how many pixels of space this renderer has. The actual world space size is dictated by this and PowerUI.WorldUI.SetResolution. The amount of pixels and pixels per world unit (resolution).

Parameters
widthPXThe width in pixels.
heightPXThe height in pixels.

Reimplemented from PowerUI.WorldUI.

override void PowerUI.FlatWorldUI.SetOrigin ( float  x,
float  y 
)
inlinevirtual

Sets the location of the gameobjects origin relatively.

Parameters
xThe x coordinate of the origin as a value from 0->1. Zero is the left edge. Default 0.5.
yThe y coordinate of the origin as a value from 0->1. Zero is the bottom edge. Default is 0.5.

Reimplemented from PowerUI.WorldUI.

void PowerUI.FlatWorldUI.SetOrthographicSize ( )
inlineprivate
override void PowerUI.FlatWorldUI.SetResolution ( float  ppw)
inlinevirtual

Sets how many Pixels Per World unit this renderer uses. Maps directly to applying a scale. Default is 100. The actual world space size is dictated by this and PowerUI.WorldUI.SetDimensions. The amount of pixels and pixels per world unit (resolution).

Parameters
ppwPixels per world unit to use for both x and y.

Reimplemented from PowerUI.WorldUI.

override void PowerUI.FlatWorldUI.SetResolution ( int  ppwW,
int  ppwH 
)
inlinevirtual

Sets how many Pixels Per World unit this renderer uses, allowing for distortion. Maps directly to applying a scale. Default is 100 on each axis. The actual world space size is dictated by this and PowerUI.WorldUI.SetDimensions. The amount of pixels and pixels per world unit (resolution).

Parameters
ppwWPixels per world unit to use for the x axis.
ppwHPixels per world unit to use for the y axis.

Reimplemented from PowerUI.WorldUI.

Member Data Documentation

GameObject PowerUI.FlatWorldUI.CameraObject

The internal camera's gameobject being used.

int PowerUI.FlatWorldUI.DefaultLayer =-1
private

The default layer to use for rendering FlatWorldUI's. If not set the PowerUI layer is used, Change by using yourWorldUI.Layer.

float PowerUI.FlatWorldUI.GlobalOffset =-150f
static

Global position offset.

FlatWorldUIHandler PowerUI.FlatWorldUI.Handler
private

A handler which ensures the camera remains the right size.

bool PowerUI.FlatWorldUI.RequiresOffset
private

Flat world UI's get stacked up on top of each other in virtual space. This is true if it will update the offset of one UI to another when SetDimensions is called.

Camera PowerUI.FlatWorldUI.SourceCamera

The internal camera being used to render it flat.

Texture PowerUI.FlatWorldUI.Texture

The raw texture. Note that for Unity Pro users, this is always a RenderTexture (and a Texture2D for free users).

Property Documentation

Texture PowerUI.FlatWorldUI.texture
get

Alias for Texture.