Home › Page › UghSprite

UghSprite

Inherits from MonoBehaviour

Any visual Ugh element inherits ultimately from UghSprite, including UghButton, UghSlider, and UghToggle, to list a few.

Variables
name type description
anchor UghSprite.Anchor The corner or custom point that the UghSprite is anchored to
customAnchorOffset Vector3 The offset values for a custom anchor
flippedHorizontal boolean Is the UghSprite flipped horizonally?
flippedVertical boolean Is the UghSprite flipped vertically?
normal UghSpriteDefinition The default UghSpriteDefinition for this button
Prototype UghSpritePrototype The current UghSpritePrototype for this button
Offset Vector3 The offset of the UghSprite
Functions
name type description
GetLocalCenter Vector3 Returns the local center of the UghControl
GetLocalOrigin Vector3 Returns the local origin of the UghControl
GetParentPublisher UghPublisher Returns the UghPublisher which this UghControl belongs to, or null if none
UpdateMesh void Updates this control's mesh
Class Variables
name type description
Anchor enum Enum for different common anchor positions
AnchorToTextAnchor TextAnchor Converts an Anchor enum into a TextAnchor enum
TextAnchorToAnchor UghSprite.Anchor Converts a TextAnchor enum into an Anchor enum
Class Functions
name type description
ForceUpdateAllUghSpriteMeshes void Forces an UpdateMesh on all UghSprites in the Scene
GetOffsetForAnchor Vector3 Returns the Vector3 offset for a given Anchor value

_

Using UghSprite in script

UghSprite is the core component of most Ugh assets and is therefore the base of most other Ugh scripting.

It is handled primarily through the Unity Inspector and the hierarchy view. A tutorial for using and implementing an UghSprite in the inspector can be found here.

UghSprites can be interacted with in script as well. a good example would be modifying the scale of the UghSprite or it’s position to facilitate interesting effects like a throbbing sprite animation of the UghSprite asset.

UghSprite Class Functions

These functions are for providing useful information for interacting with UghSprites. They return the local Center, Origin, or the UghPublisher the UghSprite belongs to.

The UpdateMesh function provides a way to update any changes made to an UghSprite in script immediately.

public Vector3 GetLocalCenter();
public Vector3 GetLocalOrigin();
public UghPublisher GetParentPublisher();
public void UpdateMesh();

UghSprite has two static class functions for updating and getting information from UghSprites

public static void ForceUpdateAllUghSpriteMeshes()

This function is provided in the Ugh menu and is used for updating all the UghSprite assets in the current scene.

and,

public static Vector3 GetOffsetForAnchor(Anchor anchor, Vector3 customAnchorOffset)

This function provides the user with the current offset Vector of a passed in Anchor type.