Detailed Description

Provides some convenience methods for drawing to a texture.

Inheritance diagram for PowerUI.DynamicTexture:
PowerUI.ImageFormat

Public Member Functions

 DynamicTexture (int width, int height)
 Creates a new dynamic texture of the given dimensions. More...
 
 DynamicTexture ()
 Creates an empty dynamic texture. Note that this is used internally by canvas. If used, you must call Resize to set it up. More...
 
void ResizeX (int width)
 Resize this texture on the X axis. More...
 
void ResizeY (int height)
 Resize this texture on the Y axis. More...
 
bool Resize (int width, int height, bool clear)
 Resize this texture on the X and Y axis, optionally only doing so if dimensions aren't zero. More...
 
void Fill (VectorPath path, Color32 colour)
 Fills the given path into this texture. More...
 
void Refresh ()
 Requests the image to be redrawn. The Flush method will end up being called (if you use it). More...
 
void RequestPaint ()
 Requests for this image to be flushed on the next update. More...
 
void Destroy ()
 Tidies up this context. More...
 
void DrawPixel (int x, int y, Color32 colour)
 Draws a pixel at the given x/y coordinates to the atlas. More...
 
void DrawLine (int x, int y, int x2, int y2, Color32 colour)
 Draws a line on the atlas from one point to another. More...
 
void DrawCircle (int x0, int y0, int radius, Color32 colour)
 Draws a filled circle on the atlas. More...
 
virtual void Flush ()
 Override this to use the special update queue - essentially it avoids spamming writing out pixels (canvas does this part) and also avoids spam redrawing the actual graphic (but canvas doesn't do this; metering that is up to you). More...
 
void Clear ()
 Wipes the graphic clean using transparent black. More...
 
void Clear (Color32 clearColour)
 Wipes the graphic clean. More...
 
override string[] GetNames ()
 The set of lowercase file types that this format will handle. More...
 
override Material GetImageMaterial (ShaderSet shaders)
 A single-frame image material. Used for e.g. videos and animations. More...
 
override ImageFormat Instance ()
 Creates an instance of this format. More...
 
override void ClearX ()
 Resets this image format container. More...
 
- Public Member Functions inherited from PowerUI.ImageFormat
virtual int GetAtlasID ()
 Get the identifier used for this content on an atlas. More...
 
Material GetImageMaterial ()
 A single-frame image material using the standard UI shader set. Used for e.g. videos and animations. More...
 
virtual bool InternallyCached (Location path, ImagePackage package)
 Some formats may cache their result internally. This checks and updates if it has. More...
 
virtual bool LoadFromAsset (UnityEngine.Object asset, ImagePackage package)
 Attempt to load the image from a Unity resource. More...
 
virtual bool LoadData (byte[] data, ImagePackage package)
 Loads the raw block of data into an object of this format. More...
 
virtual void OnLayout (RenderableData context, LayoutBox box, out float width, out float height)
 Called when the host element is drawing. More...
 
virtual void GoingOnDisplay (Css.RenderableData context)
 Called when this image is going to be displayed. More...
 
virtual void GoingOffDisplay ()
 Called when this image is going to stop being displayed. More...
 
virtual bool DrawToAtlas (TextureAtlas atlas, AtlasLocation location)
 Draws this image to the given atlas. More...
 

Static Public Member Functions

static void Update ()
 Repaints dynamic textures, writing out their pixels. More...
 

Public Attributes

Color32[] Pixels
 The pixels of this texture. More...
 
Scanner Rasteriser
 The rasteriser used to fill with. More...
 

Package Attributes

bool RefreshRequired
 True if this texture needs a refresh this frame. More...
 

Properties

override FilterMode FilterMode [get, set]
 The filter mode of this dynamic texture. The default filtering is point. More...
 
Texture2D Texture [get]
 The texture. More...
 
override bool Isolate [get]
 
override int Height [get]
 
override int Width [get]
 
override bool Loaded [get]
 
- Properties inherited from PowerUI.ImageFormat
virtual int Height [get]
 The height of the image. More...
 
virtual int Width [get]
 The width of the image. More...
 
virtual FilterMode FilterMode [get, set]
 Get/set the filter mode. More...
 
virtual bool Loaded [get]
 Is this image loaded? More...
 
virtual bool Isolate [get]
 Should this image be isolated - i.e. off atlas. More...
 

Private Member Functions

void Repaint ()
 Called by the update system to redraw this texture (only if it requires it). More...
 

Private Attributes

Material IsolatedMaterial
 An isolated material for this image. More...
 
Texture2D Texture_
 A placeholder texture which is only used by the atlas. More...
 
DynamicTexture NextToUpdate
 Next in the queue. More...
 

Static Private Attributes

static DynamicTexture ToUpdate =null
 The pending queue of textures which require updates. More...
 

Constructor & Destructor Documentation

PowerUI.DynamicTexture.DynamicTexture ( int  width,
int  height 
)
inline

Creates a new dynamic texture of the given dimensions.

Parameters
widthThe width of the texture.
heightThe height of the texture.
PowerUI.DynamicTexture.DynamicTexture ( )
inline

Creates an empty dynamic texture. Note that this is used internally by canvas. If used, you must call Resize to set it up.

Member Function Documentation

void PowerUI.DynamicTexture.Clear ( )
inline

Wipes the graphic clean using transparent black.

void PowerUI.DynamicTexture.Clear ( Color32  clearColour)
inline

Wipes the graphic clean.

Parameters
clearColourThe colour to set the whole graphic to.
override void PowerUI.DynamicTexture.ClearX ( )
inlinevirtual

Resets this image format container.

Reimplemented from PowerUI.ImageFormat.

void PowerUI.DynamicTexture.Destroy ( )
inline

Tidies up this context.

void PowerUI.DynamicTexture.DrawCircle ( int  x0,
int  y0,
int  radius,
Color32  colour 
)
inline

Draws a filled circle on the atlas.

Parameters
x0The x coordinate of the circles center in pixels from the left.
y0The y coordinate of the circles center in pixels from the bottom.
radiusThe radius of the circle, in pixels.
colourThe colour of the circle.
void PowerUI.DynamicTexture.DrawLine ( int  x,
int  y,
int  x2,
int  y2,
Color32  colour 
)
inline

Draws a line on the atlas from one point to another.

Parameters
xThe x coordinate in pixels from the left of the start of the line.
yThe y coordinate in pixels from the left of the start of the line.
x2The x coordinate in pixels from the left of the end of the line.
y2The y coordinate in pixels from the left of the end of the line.
colourThe colour of the line.
void PowerUI.DynamicTexture.DrawPixel ( int  x,
int  y,
Color32  colour 
)
inline

Draws a pixel at the given x/y coordinates to the atlas.

Parameters
xThe x coordinate in pixels from the left of the texture.
yThe y coordinate in pixels from the bottom of the texture.
colourThe colour of the pixel to draw.
void PowerUI.DynamicTexture.Fill ( VectorPath  path,
Color32  colour 
)
inline

Fills the given path into this texture.

virtual void PowerUI.DynamicTexture.Flush ( )
inlinevirtual

Override this to use the special update queue - essentially it avoids spamming writing out pixels (canvas does this part) and also avoids spam redrawing the actual graphic (but canvas doesn't do this; metering that is up to you).

override Material PowerUI.DynamicTexture.GetImageMaterial ( ShaderSet  shaders)
inlinevirtual

A single-frame image material. Used for e.g. videos and animations.

Reimplemented from PowerUI.ImageFormat.

override string [] PowerUI.DynamicTexture.GetNames ( )
inlinevirtual

The set of lowercase file types that this format will handle.

Reimplemented from PowerUI.ImageFormat.

override ImageFormat PowerUI.DynamicTexture.Instance ( )
inlinevirtual

Creates an instance of this format.

Reimplemented from PowerUI.ImageFormat.

void PowerUI.DynamicTexture.Refresh ( )
inline

Requests the image to be redrawn. The Flush method will end up being called (if you use it).

void PowerUI.DynamicTexture.Repaint ( )
inlineprivate

Called by the update system to redraw this texture (only if it requires it).

void PowerUI.DynamicTexture.RequestPaint ( )
inline

Requests for this image to be flushed on the next update.

bool PowerUI.DynamicTexture.Resize ( int  width,
int  height,
bool  clear 
)
inline

Resize this texture on the X and Y axis, optionally only doing so if dimensions aren't zero.

Parameters
widthThe new width.
heightThe new height.
void PowerUI.DynamicTexture.ResizeX ( int  width)
inline

Resize this texture on the X axis.

Parameters
widthThe new width.
void PowerUI.DynamicTexture.ResizeY ( int  height)
inline

Resize this texture on the Y axis.

Parameters
heightThe new height.
static void PowerUI.DynamicTexture.Update ( )
inlinestatic

Repaints dynamic textures, writing out their pixels.

Member Data Documentation

Material PowerUI.DynamicTexture.IsolatedMaterial
private

An isolated material for this image.

DynamicTexture PowerUI.DynamicTexture.NextToUpdate
private

Next in the queue.

Color32 [] PowerUI.DynamicTexture.Pixels

The pixels of this texture.

Scanner PowerUI.DynamicTexture.Rasteriser

The rasteriser used to fill with.

bool PowerUI.DynamicTexture.RefreshRequired
package

True if this texture needs a refresh this frame.

Texture2D PowerUI.DynamicTexture.Texture_
private

A placeholder texture which is only used by the atlas.

DynamicTexture PowerUI.DynamicTexture.ToUpdate =null
staticprivate

The pending queue of textures which require updates.

Property Documentation

override FilterMode PowerUI.DynamicTexture.FilterMode
getset

The filter mode of this dynamic texture. The default filtering is point.

override int PowerUI.DynamicTexture.Height
get
override bool PowerUI.DynamicTexture.Isolate
get
override bool PowerUI.DynamicTexture.Loaded
get
Texture2D PowerUI.DynamicTexture.Texture
get

The texture.

override int PowerUI.DynamicTexture.Width
get