Home › Page › UghSpritePrototype


Revision for “UghSpritePrototype” created on 17 April, 2013 @ 18:55

Inherits from ScriptableObject. UghSpritePrototype defines an individual sprite held inside a sprite atlas.  Variables that define the location and size of the sprite are automatically filled with values when a sprite atlas is generated.  Additional variables define the appearance and behavior of the sprite, and must be adjusted by the user. <a title="UghSprite" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite">UghSprite</a> uses UghSpritePrototype to compose a sprite. <a title="UghSpriteDefinition" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughspritedefinition">UghSpriteDefinition</a> holds a list of UghSpritePrototypes (inside of the <a title="UghSpriteResolutionDefinition" href="http://ugh.graveck.com/wiki/ughspriteresolutiondefinition">UghSpriteResolutionDefinition</a> helper class) and chooses an appropriate UghSpritePrototype based on screen resolution at runtime. [table caption="Variables" colwidth=20%|20%] name, type, description edgeInsets, EdgePixels, "Calculated at runtime.  The bounding rectangle of the sprite in the atlas, in Unity units." edgePixelCrops, EdgePixels, The number of pixels to shave off of each side.  Useful to get rid of edge artifacts after PVRTC compression. edgePixelInsets, EdgePixels, "The bounding rectangle of the sprite in the atlas, in pixels." insetScaling, InsetScaling, A hint to <a title="UghSprite" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite">UghSprite</a> on how to stretch UVs when the sprite is scaled. material, Material, The atlas material that holds the sprite. nativePixelSize, Vector3, "The width and height of the sprite, in pixels." nativeUVRect, Rect, The UV coordinates of the sprite in the atlas. pixelHeight, int, Calculated at runtime.  The actual height of the sprite (including scaling and crops) in pixels. pixelSize, Vector3, Calculated at runtime.  The actual size of the sprite (including scaling and crops) in pixels. pixelWidth, int, "Calculated at runtime.  The actual width of the sprite (including scaling and crops) in pixels." size, Vector3, "Calculated at runtime.  The size of the sprite, in Unity units." sourceUVRect, Rect, Calculated at runtime.  The actual UV coordinates of the sprite in the atlas (including scaling and crops.) [/table] [table caption="Functions" colwidth=20%] name, type, description CreateSprite, GameObject, Generates an UghSprite (or derivative) that uses this UghSpritePrototype. UpdatePrototype, void, Calculates the value of all variables that are filled at runtime. [/table] &nbsp; <strong>Using UghSpritePrototype in Script</strong> [sourcecode language="csharp"]public GameObject CreateSprite(Type type)[/sourcecode] Given an <a title="UghSprite" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite">UghSprite</a> Type (or derivative,) this function will return a game object with the appropriate components, with the Prototype variable filled in with this UghSpritePrototype.  For example:  Calling <code>CreateSprite(typeof(UghButton))</code> will return a GameObject that has an <a title="UghButton" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughbutton">UghButton</a> component. [sourcecode language="csharp"]public void UpdatePrototype()[/sourcecode] This function will calculate values for all variables that are determined at runtime.  This function is automatically called once during OnEnable.  Call this function if you change any variables at runtime and need to immediately update the calculated variables.

OldNewDate CreatedAuthorActions
17 April, 2013 @ 18:55 admin
29 March, 2013 @ 15:24 admin
29 March, 2013 @ 15:24 [Autosave] admin
29 March, 2013 @ 15:13 admin
29 March, 2013 @ 15:13 admin
29 March, 2013 @ 14:57 admin
29 March, 2013 @ 14:56 admin
29 March, 2013 @ 14:54 admin
29 March, 2013 @ 14:53 admin
18 March, 2013 @ 17:18 admin
18 March, 2013 @ 17:17 admin
18 March, 2013 @ 17:16 admin
11 March, 2013 @ 18:32 admin
11 March, 2013 @ 18:27 admin
7 March, 2013 @ 22:53 admin
7 March, 2013 @ 22:48 admin
7 March, 2013 @ 22:48 admin
7 March, 2013 @ 22:47 admin
7 March, 2013 @ 22:47 admin
7 March, 2013 @ 22:36 admin
7 March, 2013 @ 22:33 admin
7 March, 2013 @ 22:32 admin
7 March, 2013 @ 22:30 admin