Home › Page › UghAlign

UghAlign

Revision for “UghAlign” created on 17 April, 2013 @ 18:13 [Autosave]

Title
UghAlign
Content
Inherits from MonoBehaviour Use UghAlign to keep a Transform aligned relative to the screen or another UghSprite. To keep groups of Transforms (such as UghButtons and UghSprites) aligned together:  Create a new GameObject.  Add an UghAlign component to the object.  Place the desired Transforms as children of this new object.  Finally, change any settings of the UghAlign component to match your desired behavior. Click <a title="Ugh Scripting Reference" href="http://ugh.graveck.com/wiki/ugh-scripting-reference">here</a> to go to the UghAlign Tutorial. [table caption="Variables" colwidth=20%|20%] name, type, description alignTo<strong>, </strong>UghSprite, "The sprite to align this transform to. If this is set to null, the transform will align itself to the screen." alignX<strong>, </strong>boolean, "If false, the transform's x-coordinate will not change." alignY<strong>, </strong>boolean, "If false, the transform's y-coordinate will not change." IsDirty<strong>, </strong>boolean, Returns true if the UghAlign needs to be repositioned. pointToAnchorTo<strong>, </strong><a title="UghSprite" href="http://ugh.graveck.com/wiki/ugh-scripting-reference/ughsprite">UghSprite</a>.Anchor, "Tells the UghAlign which part of the alignTo sprite (or the screen) to align itself to." customAnchorOffset<strong>, </strong>Vector3, "The custom offset from the alignTo sprite, or the screen. Note: only takes effect if pointToAnchorTo is equal to Custom." useWorldSpace<strong>, </strong>boolean, Set to true to align using world space and false otherwise. [/table] [table caption="Functions" colwidth=20%|20%] name, type, description Align<strong>, </strong>void, Align the transform this UghAlign is attached to. Should not need to be called manually if AutoUpdate is set to true. [/table] [table caption="Class Variables" colwidth=20%|20%] name, type, description AutoUpdate<strong>,</strong>boolean, "If true, all UghAligns update their positions automatically if their alignTo sprites move or their IsDirty is set to true." [/table] [table caption="Class Functions" colwidth=20%|20%] name, type, description AlignToScreen<strong>, </strong>void, Aligns the given transform to the given UghSprite.Anchor on the screen. AlignToSprite, void, Aligns the given transform to a sprite. [/table] _ <strong>Using UghAlign in script</strong> UghAligns are typically managed completely from the Unity hierarchy and inspector. A tutorial for using UghAligns in the hierarchy and inspector views can be found <span style="text-decoration: underline;">here</span>. UghAligns can also be modified via script.  A good example of modifying an UghAlign through script is to move the object that the UghAlign is anchored to, but prevent the UghAlign's position from also changing. In such cases, make sure to set UghAlign's AutoUpdate member to false.  If an UghAlign is not using AutoUpdate, you may cause it to align at any time by calling the Align() method. <strong>Using UghAlign's class functions</strong> UghAlign has two static class functions that can be used to perform a one-time align on any transform. [sourcecode language="csharp"]static void AlignToScreen(Transform transform, UghSprite.Anchor anchor, Vector3 customOffset)[/sourcecode] This function will align the given Transform to a point on the screen which corresponds to the given Anchor. For example, passing UghSprite.Anchor.TopCenter as the Anchor would align the center of the Transform with the center of the top edge of the screen. [sourcecode language="csharp"]static void AlignToSprite(Transform transform, UghSprite alignTo, UghSprite.Anchor anchor, Vector3 customOffset)[/sourcecode] This function will align the given Transform to the given UghSprite according to the given Anchor.  For example, if you align a Transform to an UghSprite using the UghSprite.Anchor.BottomRight, the center of the Transform will align with the bottom right corner of the UghSprite.
Excerpt


OldNewDate CreatedAuthorActions
17 April, 2013 @ 18:13 [Autosave] admin
17 April, 2013 @ 17:58 admin
17 April, 2013 @ 17:55 admin
2 April, 2013 @ 17:09 admin
2 April, 2013 @ 17:08 admin
2 April, 2013 @ 17:01 admin
28 March, 2013 @ 20:49 admin
28 March, 2013 @ 20:33 admin
28 March, 2013 @ 20:33 admin
28 March, 2013 @ 20:32 admin
18 March, 2013 @ 17:44 admin
18 March, 2013 @ 17:43 admin
18 March, 2013 @ 17:39 admin
18 March, 2013 @ 16:35 admin
18 March, 2013 @ 16:31 admin
18 March, 2013 @ 16:31 admin
18 March, 2013 @ 16:30 admin
18 March, 2013 @ 16:30 admin
18 March, 2013 @ 16:26 admin
18 March, 2013 @ 15:57 admin
18 March, 2013 @ 14:34 admin
18 March, 2013 @ 14:28 admin
18 March, 2013 @ 14:28 admin
18 March, 2013 @ 14:27 admin
18 March, 2013 @ 14:27 admin
18 March, 2013 @ 14:24 admin
14 March, 2013 @ 15:57 admin
14 March, 2013 @ 15:49 admin
14 March, 2013 @ 15:48 admin
14 March, 2013 @ 15:47 admin
14 March, 2013 @ 15:36 admin
14 March, 2013 @ 15:27 admin
14 March, 2013 @ 15:26 admin
14 March, 2013 @ 14:44 admin
13 March, 2013 @ 21:43 admin
13 March, 2013 @ 21:42 admin
13 March, 2013 @ 21:41 admin
13 March, 2013 @ 21:41 admin
13 March, 2013 @ 20:57 admin
13 March, 2013 @ 20:55 admin
13 March, 2013 @ 20:54 admin
13 March, 2013 @ 20:52 admin
13 March, 2013 @ 20:51 admin
13 March, 2013 @ 20:51 admin
13 March, 2013 @ 20:47 admin
13 March, 2013 @ 20:44 admin
13 March, 2013 @ 20:41 admin
13 March, 2013 @ 20:38 admin
13 March, 2013 @ 20:34 admin
13 March, 2013 @ 20:27 admin
13 March, 2013 @ 20:25 admin
13 March, 2013 @ 20:06 admin
13 March, 2013 @ 20:05 admin
13 March, 2013 @ 19:50 admin
13 March, 2013 @ 19:23 admin
13 March, 2013 @ 19:22 admin
13 March, 2013 @ 17:29 admin
13 March, 2013 @ 15:56 admin
13 March, 2013 @ 15:44 admin
12 March, 2013 @ 22:02 admin
12 March, 2013 @ 21:48 admin
12 March, 2013 @ 21:47 admin
12 March, 2013 @ 21:46 admin
12 March, 2013 @ 21:27 admin
12 March, 2013 @ 16:41 admin
12 March, 2013 @ 16:33 admin
12 March, 2013 @ 16:33 admin
12 March, 2013 @ 16:24 admin
12 March, 2013 @ 16:04 admin
12 March, 2013 @ 15:18 admin
12 March, 2013 @ 15:18 admin
8 March, 2013 @ 23:01 admin
8 March, 2013 @ 23:01 admin
8 March, 2013 @ 22:50 admin
8 March, 2013 @ 22:49 admin
8 March, 2013 @ 22:48 admin
8 March, 2013 @ 22:48 admin
8 March, 2013 @ 22:23 admin
8 March, 2013 @ 22:21 admin
8 March, 2013 @ 20:20 admin
8 March, 2013 @ 20:11 admin
8 March, 2013 @ 20:10 admin
8 March, 2013 @ 19:19 admin
8 March, 2013 @ 19:19 admin
8 March, 2013 @ 19:11 admin
8 March, 2013 @ 19:10 admin
8 March, 2013 @ 18:55 admin
8 March, 2013 @ 18:54 admin
8 March, 2013 @ 18:53 admin
8 March, 2013 @ 18:23 admin
8 March, 2013 @ 18:15 admin
8 March, 2013 @ 18:12 admin
8 March, 2013 @ 17:46 admin
7 March, 2013 @ 21:29 admin
7 March, 2013 @ 21:13 admin
6 March, 2013 @ 21:49 admin
6 March, 2013 @ 21:49 admin