Home › Page › UghButton

UghButton

Revision for “UghButton” created on 22 July, 2013 @ 20:59 [Autosave]

Title
UghButton
Content
Inherits from <a title="UghControl" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughcontrol">UghControl</a> Each UghButton runs a function when you press it. They can be combined with an UghPublisher or used on their own. For more information on the relationship between UghButtons and UghPublishers, see the UghPublisher <span style="text-decoration: underline;">tutorial page</span>. [table caption="Variables" colwidth=20%|20%] name, type, description autoSizeCollider, boolean, Do we automatically resize the collider for this button? mouseOver, <a title="UghSpriteDefinition" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughspritedefinition">UghSpriteDefinition</a>, The sprite definition for when the mouse hovers over the button pressed, <a title="UghSpriteDefinition" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughspritedefinition">UghSpriteDefinition</a>, The sprite definition for when the mouse is clicking on or a finger is tapping on the button [/table] [table caption="Functions" colwidth=20%|20%] name, type, description OnDown, event, An event fired when the button is pressed down OnUghInputDown, void,Called when the mouse clicks or a finger taps on this button OnUghInputUp, void,Called when the mouse or finger drags off this button OnUghInputUpAsButton, void,Called when the mouse stops clicking or a finger lifts up when over this button OnPressed, event, "An event fired when the button is released with the input over the button, at the same time as OnUghInputAsButton" [/table] [table caption="Inherited Variables" colwidth=20%|20%] name, type, description anchor, <a title="UghSprite.Anchor" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite/anchor">UghSprite</a>.Anchor, The corner or custom point that the UghControl 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? HotFingerID, int, The ID of the finger interacting with this control isLegalControl, boolean, Is this a legal control? normal, <a title="UghSpriteDefinition" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughspritedefinition">UghSpriteDefinition</a>, The default UghSpriteDefinition for this button Prototype, <a title="UghSpritePrototype" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughspriteprototype-2">UghSpritePrototype</a>, The current UghSpritePrototype for this button Offset, Vector3, The offset of the UghSprite [/table] [table caption="Inherited Functions" colwidth=20%|20%] name, type, description GetLocalCenter, Vector3, Returns the local center of the UghControl GetLocalOrigin, Vector3, Returns the local origin of the UghControl GetParentPublisher, <a title="UghPublisher" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughpublisher">UghPublisher</a>, "Returns the UghPublisher which this UghControl belongs to, or null if none" UpdateMesh, void, Updates this control's mesh [/table] [table caption="Inherited Class Variables" colwidth=20%|20%] name, type, description Anchor, enum, Enum for different common anchor positions AnchorToTextAnchor, TextAnchor, Converts an Anchor enum into a TextAnchor enum TextAnchorToAnchor, <a title="UghSprite" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite">UghSprite.Anchor</a>, Converts a TextAnchor enum into an Anchor enum theOnlyLegalControls, <a title="UghControl" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughcontrol">UghControl</a>[], Array of all currently legal controls [/table] [table caption="Inherited Class Functions" colwidth=20%|20%] name, type, description ForceUpdateAllUghSpriteMeshes, void, Forces every UghSprite's mesh to update GetOffsetForAnchor, Vector3, Returns the Vector3 offset for a given Anchor value [/table] _ <strong>Understanding the UghButton class</strong> The functions OnUghInputDown, OnUghInputUp, and OnUghInputUpAsButton are called by the UghInput object in the scene. OnUghInputDown is called when the user clicks on or puts their finger on the button. OnUghInputUp is called when the input leaves the button, whether because the input stopped entirely or just moved off of the button. OnUghInputUpAsButton only fires if the input started above the button and ends above the button. This is also the function that means the button was "actually pressed" and the function set in its parent UghPublisher will be run. [sourcecode language="csharp"] public override IEnumerator OnUghInputDown(); public override void OnUghInputUp(); public override void OnUghInputUpAsButton(); [/sourcecode] There are two events on every UghButton: OnDown and OnPressed. In the event that you want to use an UghButton element without a parent UghPublisher, you should register for these events. The OnDown event will fire when the down state of the button changes. The event passes the button itself and a boolean for the state of the button. If you are registering for the OnDown event and only want your program to do something when the down state changes to true, make sure to check this boolean. [sourcecode language="csharp"] public event System.Action&lt;Ughbutton,bool&gt; OnDown; public event System.Action OnPressed; [/sourcecode] The OnPressed event fires under exactly the same circumstances that OnUghInputUpAsButton runs.
Excerpt


OldNewDate CreatedAuthorActions
22 July, 2013 @ 20:59 [Autosave] admin
17 April, 2013 @ 17:54 admin
17 April, 2013 @ 17:53 admin
2 April, 2013 @ 15:53 admin
2 April, 2013 @ 15:52 admin
2 April, 2013 @ 15:51 admin
2 April, 2013 @ 15:45 admin
29 March, 2013 @ 17:24 admin
29 March, 2013 @ 17:21 admin
18 March, 2013 @ 21:33 admin
18 March, 2013 @ 21:31 admin
18 March, 2013 @ 14:43 admin
18 March, 2013 @ 14:39 admin
15 March, 2013 @ 16:30 admin
15 March, 2013 @ 16:30 admin
15 March, 2013 @ 16:30 admin
15 March, 2013 @ 16:12 admin
15 March, 2013 @ 16:11 admin
15 March, 2013 @ 16:11 admin
12 March, 2013 @ 18:15 admin
11 March, 2013 @ 19:05 admin
11 March, 2013 @ 17:45 admin
8 March, 2013 @ 21:11 admin
8 March, 2013 @ 21:04 admin
8 March, 2013 @ 21:03 admin
8 March, 2013 @ 21:03 admin
8 March, 2013 @ 20:46 admin
8 March, 2013 @ 20:46 admin
8 March, 2013 @ 20:43 admin
8 March, 2013 @ 20:34 admin
8 March, 2013 @ 20:32 admin
8 March, 2013 @ 20:24 admin
8 March, 2013 @ 19:08 admin
8 March, 2013 @ 19:08 admin
8 March, 2013 @ 19:08 admin
8 March, 2013 @ 19:07 admin
8 March, 2013 @ 19:07 admin
8 March, 2013 @ 19:06 admin
8 March, 2013 @ 19:03 admin
8 March, 2013 @ 18:38 admin
8 March, 2013 @ 18:38 admin
8 March, 2013 @ 18:36 admin
8 March, 2013 @ 16:26 admin
7 March, 2013 @ 18:08 admin
7 March, 2013 @ 18:05 admin
7 March, 2013 @ 18:04 admin
7 March, 2013 @ 18:02 admin
7 March, 2013 @ 17:59 admin
6 March, 2013 @ 20:11 admin
6 March, 2013 @ 20:11 admin