UnityEssentials
Small but useful tools and features for Unity
|
Extensions for the RectTransform component More...
Static Public Member Functions | |
static Rect | GetWorldRect (this RectTransform rt) |
Get the corners of the RectTransform in world space. More... | |
static MinMax01 | GetAnchors (this RectTransform rt) |
The normalized position in the parent RectTransform that the corners is anchored to. More... | |
static void | SetAnchors (this RectTransform rt, MinMax01 anchors) |
Sets the normalized position in the parent RectTransform that the corners is anchored to. More... | |
static RectTransform | GetParent (this RectTransform rt) |
The RecTransform parent of the RectTransform. More... | |
static float | GetWidth (this RectTransform rt) |
The width of the RectTransform, measured from the X position. More... | |
static float | GetHeight (this RectTransform rt) |
The height of the RectTransform, measured from the Y position. More... | |
static Vector2 | GetSize (this RectTransform rt) |
The width and the height of the RectTransform, measured from the (X,Y) position. More... | |
static void | SetWidth (this RectTransform rt, float width) |
Sets the width of the RectTransform keeping the current anchors. More... | |
static void | SetHeight (this RectTransform rt, float height) |
Sets the height of the RectTransform keeping the current anchors. More... | |
static void | SetSize (this RectTransform rt, float width, float height) |
Sets the width and the height of the RectTransform keeping the current anchors. More... | |
static void | SetSize (this RectTransform rt, Vector2 size) |
Sets the width and the height of the RectTransform keeping the current anchors. More... | |
static Vector2 | GetLeft (this RectTransform rt) |
The center of the left edge. More... | |
static Vector2 | GetRight (this RectTransform rt) |
The center of the right edge. More... | |
static Vector2 | GetTop (this RectTransform rt) |
The center of the top edge. More... | |
static Vector2 | GetBottom (this RectTransform rt) |
The center of the bottom edge. More... | |
static void | SetLeft (this RectTransform rt, float distance) |
Sets the distance of the distance from the left edge to the parent's left edge regardless of the anchor position. More... | |
static void | SetRight (this RectTransform rt, float distance) |
Sets the distance of the distance from the left edge to the parent's left edge regardless of the anchor position. More... | |
static void | SetTop (this RectTransform rt, float top) |
Sets the distance of the distance from the top edge to the parent's top edge regardless of the anchor position. More... | |
static void | SetBottom (this RectTransform rt, float distance) |
Sets the distance of the distance from the bottom edge to the parent's bottom edge regardless of the anchor position. More... | |
static void | Left (this RectTransform rt, float distance) |
Moves the edge to a distance towards the center from the same edge of the parent. More... | |
static void | Right (this RectTransform rt, float distance) |
Moves the edge to a distance towards the center from the same edge of the parent. More... | |
static void | Top (this RectTransform rt, float distance) |
Moves the edge to a distance towards the center from the same edge of the parent. More... | |
static void | Bottom (this RectTransform rt, float distance) |
Moves the edge to a distance towards the center from the same edge of the parent. More... | |
static void | SetLeftFrom (this RectTransform rt, MinMax01 anchor, float distance) |
Repositions the requested edge relative to the passed anchor. More... | |
static void | SetRightFrom (this RectTransform rt, MinMax01 anchor, float distance) |
Repositions the requested edge relative to the passed anchor. More... | |
static void | SetTopFrom (this RectTransform rt, MinMax01 anchor, float distance) |
Repositions the requested edge relative to the passed anchor. More... | |
static void | SetBottomFrom (this RectTransform rt, MinMax01 anchor, float distance) |
Repositions the requested edge relative to the passed anchor. More... | |
static void | SetRelativeLeft (this RectTransform rt, float distance) |
Moves the edge to the requested position relative to the current position. More... | |
static void | SetRelativeRight (this RectTransform rt, float distance) |
Moves the edge to the requested position relative to the current position. More... | |
static void | SetRelativeTop (this RectTransform rt, float distance) |
Moves the edge to the requested position relative to the current position. More... | |
static void | SetRelativeBottom (this RectTransform rt, float distance) |
Moves the edge to the requested position relative to the current position. More... | |
static void | MoveLeft (this RectTransform rt, float left=0) |
Sets the position of the RectTransform relative to the parent's Left side, regardless of anchor setting. More... | |
static void | MoveRight (this RectTransform rt, float right=0) |
Sets the position of the RectTransform relative to the parent's Right side, regardless of anchor setting. More... | |
static void | MoveTop (this RectTransform rt, float top=0) |
Sets the position of the RectTransform relative to the parent's Top side, regardless of anchor setting. More... | |
static void | MoveBottom (this RectTransform rt, float bottom=0) |
Sets the position of the RectTransform relative to the parent's Bottom side, regardless of anchor setting. More... | |
static void | MoveLeftInside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the child left edge with the parent left edge. More... | |
static void | MoveRightInside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the child left edge with the parent right edge. More... | |
static void | MoveTopInside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the child left edge with the parent left top. More... | |
static void | MoveBottomInside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the child left edge with the parent bottom edge. More... | |
static void | MoveLeftOutside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the right edge with the parent left edge. More... | |
static void | MoveRightOutside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the left edge with the parent right edge. More... | |
static void | MoveTopOutside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the bottom edge with the parent top edge. More... | |
static void | MoveBottomOutside (this RectTransform rt, float distance=0) |
Moves the RectTransform to align the top edge with the parent bottom edge. More... | |
static void | Move (this RectTransform rt, float x, float y) |
Moves the RectTransform to the given point in parent space, considering (0, 0) to be the parent's lower-left corner. More... | |
static void | Move (this RectTransform rt, Vector2 point) |
Moves the RectTransform to the given point in parent space, considering (0, 0) to be the parent's lower-left corner. More... | |
static void | MoveInside (this RectTransform rt, float x, float y) |
Moves the RectTransform relative to the parent's lower-le1ft corner, respecting the RT's width and height. More... | |
static void | MoveInside (this RectTransform rt, Vector2 point) |
Moves the RectTransform relative to the parent's lower-le1ft corner, respecting the RT's width and height. More... | |
static void | MoveOutside (this RectTransform rt, float x, float y) |
Moves the RectTransform relative to the parent's lower-left corner, respecting the RT's width and height. More... | |
static void | MoveOutside (this RectTransform rt, Vector2 point) |
Moves the RectTransform relative to the parent's lower-left corner, respecting the RT's width and height. More... | |
static void | MoveFrom (this RectTransform rt, MinMax01 anchor, Vector2 point) |
Moves the RectTransform relative to an arbitrary anchor point. This is effectively like setting the anchor, then moving, then setting it back, but does so without potentially getting in the way of anything else. More... | |
static void | MoveFrom (this RectTransform rt, MinMax01 anchor, float x, float y) |
Moves the RectTransform relative to an arbitrary anchor point. This is effectively like setting the anchor, then moving, then setting it back, but does so without potentially getting in the way of anything else. More... | |
static Vector2 | ParentToChildSpace (this RectTransform rt, Vector2 point) |
Translates a point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner, into the same point relative to the RectTransform's current anchor. More... | |
static Vector2 | ParentToChildSpace (this RectTransform rt, float x, float y) |
Translates a point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner, into the same point relative to the RectTransform's current anchor. More... | |
static Vector2 | ChildToParentSpace (this RectTransform rt, float x, float y) |
Translates a point (presumably the RectTransform's anchoredPosition) into the same point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner. More... | |
static Vector2 | ChildToParentSpace (this RectTransform rt, Vector2 point) |
Translates a point (presumably the RectTransform's anchoredPosition) into the same point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner. More... | |
static Vector2 | ParentToAnchorSpace (this RectTransform rt, Vector2 point) |
Normalizes a point associated with the parent object into "Anchor Space", which is to say, (0, 0) represents the parent's lower-left-hand corner, and (1, 1) represents the upper-right-hand. More... | |
static Vector2 | ParentToAnchorSpace (this RectTransform rt, float x, float y) |
Normalizes a point associated with the parent object into "Anchor Space", which is to say, (0, 0) represents the parent's lower-left-hand corner, and (1, 1) represents the upper-right-hand. More... | |
static Vector2 | AnchorToParentSpace (this RectTransform rt, float x, float y) |
Translates a normalized "Anchor Space" coordinate into a real point on the parent's reference system. More... | |
static Vector2 | AnchorToParentSpace (this RectTransform rt, Vector2 point) |
Translates a normalized "Anchor Space" coordinate into a real point on the parent's reference system. More... | |
static Vector2 | AnchorOrigin (this RectTransform rt) |
The center of the rectangle the two anchors represent, which is the origin that a RectTransform's anchoredPosition is an offset of. More... | |
static Vector2 | AnchorOrigin (MinMax01 anchor) |
The center of the rectangle the two anchors represent, which is the origin that a RectTransform's anchoredPosition is an offset of. More... | |
static Vector2 | AnchorOriginParent (this RectTransform rt) |
Translates a RectTransform's anchor origin into Parent space. More... | |
static Canvas | GetRootCanvas (this RectTransform rt) |
Returns the top-most-level canvas that this RectTransform is a child of. More... | |
static void | SetProperties (this RectTransform rectTrans, RectTransform properties) |
Sets the RectTransform position, rotation and scale to the same values in the given RectTransform. More... | |
static void | SetProperties (this RectTransform rectTrans, Vector2 anchoredPosition, Vector3 anchoredPosition3D, Vector2 anchorMax, Vector2 anchorMin, Vector2 offsetMax, Vector2 offsetMin, Vector2 pivot, Vector2 sizeDelta, Transform trans=null) |
Sets the transform properties to the given values. More... | |
static void | SetLerp (this RectTransform self, RectTransform a, RectTransform b, float t) |
Linearly interpolates between two RectTransforms. More... | |
Extensions for the RectTransform component
Definition at line 35 of file RectTransformExtensions.cs.
|
static |
The center of the rectangle the two anchors represent, which is the origin that a RectTransform's anchoredPosition is an offset of.
Definition at line 724 of file RectTransformExtensions.cs.
|
static |
The center of the rectangle the two anchors represent, which is the origin that a RectTransform's anchoredPosition is an offset of.
Definition at line 716 of file RectTransformExtensions.cs.
|
static |
Translates a RectTransform's anchor origin into Parent space.
Definition at line 736 of file RectTransformExtensions.cs.
|
static |
Translates a normalized "Anchor Space" coordinate into a real point on the parent's reference system.
x | X coordinate of a normalized point set in "Anchor Space". |
y | Y coordinate of a normalized point set in "Anchor Space". |
Definition at line 696 of file RectTransformExtensions.cs.
|
static |
Translates a normalized "Anchor Space" coordinate into a real point on the parent's reference system.
point | A normalized "Anchor Space" point of a normalized point set in "Anchor Space". |
Definition at line 705 of file RectTransformExtensions.cs.
|
static |
Moves the edge to a distance towards the center from the same edge of the parent.
distance |
Definition at line 286 of file RectTransformExtensions.cs.
|
static |
Translates a point (presumably the RectTransform's anchoredPosition) into the same point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner.
x | X coordinate of the point to translate. |
y | Y coordinate of the point to translate. |
Definition at line 643 of file RectTransformExtensions.cs.
|
static |
Translates a point (presumably the RectTransform's anchoredPosition) into the same point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner.
point | The point to translate. |
Definition at line 652 of file RectTransformExtensions.cs.
|
static |
The normalized position in the parent RectTransform that the corners is anchored to.
Definition at line 57 of file RectTransformExtensions.cs.
|
static |
The center of the bottom edge.
Definition at line 176 of file RectTransformExtensions.cs.
|
static |
The height of the RectTransform, measured from the Y position.
Definition at line 94 of file RectTransformExtensions.cs.
|
static |
The center of the left edge.
Definition at line 149 of file RectTransformExtensions.cs.
|
static |
The RecTransform parent of the RectTransform.
Definition at line 76 of file RectTransformExtensions.cs.
|
static |
The center of the right edge.
Definition at line 158 of file RectTransformExtensions.cs.
|
static |
Returns the top-most-level canvas that this RectTransform is a child of.
Definition at line 745 of file RectTransformExtensions.cs.
|
static |
The width and the height of the RectTransform, measured from the (X,Y) position.
Definition at line 103 of file RectTransformExtensions.cs.
|
static |
The center of the top edge.
Definition at line 167 of file RectTransformExtensions.cs.
|
static |
The width of the RectTransform, measured from the X position.
Definition at line 85 of file RectTransformExtensions.cs.
|
static |
Get the corners of the RectTransform in world space.
This method could behave weirdly in some cases.
Definition at line 42 of file RectTransformExtensions.cs.
|
static |
Moves the edge to a distance towards the center from the same edge of the parent.
distance |
Definition at line 262 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to the given point in parent space, considering (0, 0) to be the parent's lower-left corner.
x | X coordinate of the point to move the RectTransform to. |
y | Y coordinate of the point to move the RectTransform to. |
Definition at line 532 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to the given point in parent space, considering (0, 0) to be the parent's lower-left corner.
point | The point to move the RectTransform to. |
Definition at line 541 of file RectTransformExtensions.cs.
|
static |
Sets the position of the RectTransform relative to the parent's Bottom side, regardless of anchor setting.
bottom | Sets the position of the RectTransform relative to the parent's Bottom side. |
Definition at line 428 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the child left edge with the parent bottom edge.
distance | The distance to the parent bottom edge. |
Definition at line 476 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the top edge with the parent bottom edge.
distance | The distance between the edges |
Definition at line 521 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to an arbitrary anchor point. This is effectively like setting the anchor, then moving, then setting it back, but does so without potentially getting in the way of anything else.
rt |
Definition at line 605 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to an arbitrary anchor point. This is effectively like setting the anchor, then moving, then setting it back, but does so without potentially getting in the way of anything else.
Definition at line 597 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to the parent's lower-le1ft corner, respecting the RT's width and height.
See MoveLeftInside for more information.
x | X coordinate of the point to move the RectTransform to. |
y | Y coordinate of the point to move the RectTransform to. |
Definition at line 554 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to the parent's lower-le1ft corner, respecting the RT's width and height.
See MoveLeftInside for more information.
point | The point to move the RectTransform to. |
Definition at line 564 of file RectTransformExtensions.cs.
|
static |
Sets the position of the RectTransform relative to the parent's Left side, regardless of anchor setting.
left | Sets the position of the RectTransform relative to the parent's Left side. |
Definition at line 395 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the child left edge with the parent left edge.
distance | The distance to the parent left edge. |
Definition at line 452 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the right edge with the parent left edge.
rt | |
distance | The distance between the edges |
Definition at line 497 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to the parent's lower-left corner, respecting the RT's width and height.
See MoveLeftOutside for more information.
x | X coordinate of the point to move the RectTransform to. |
y | Y coordinate of the point to move the RectTransform to. |
Definition at line 577 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform relative to the parent's lower-left corner, respecting the RT's width and height.
See MoveLeftOutside for more information.
point | The point to move the RectTransform to. |
Definition at line 587 of file RectTransformExtensions.cs.
|
static |
Sets the position of the RectTransform relative to the parent's Right side, regardless of anchor setting.
right | Sets the position of the RectTransform relative to the parent's Right side. |
Definition at line 406 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the child left edge with the parent right edge.
distance | The distance to the parent right edge. |
Definition at line 460 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the left edge with the parent right edge.
distance | The distance between the edges |
Definition at line 505 of file RectTransformExtensions.cs.
|
static |
Sets the position of the RectTransform relative to the parent's Top side, regardless of anchor setting.
top | Sets the position of the RectTransform relative to the parent's Top side. |
Definition at line 417 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the child left edge with the parent left top.
distance | The distance to the parent top edge. |
Definition at line 468 of file RectTransformExtensions.cs.
|
static |
Moves the RectTransform to align the bottom edge with the parent top edge.
distance | The distance between the edges |
Definition at line 513 of file RectTransformExtensions.cs.
|
static |
Normalizes a point associated with the parent object into "Anchor Space", which is to say, (0, 0) represents the parent's lower-left-hand corner, and (1, 1) represents the upper-right-hand.
x | X coordinate of the point to normalize. |
y | Y coordinate of the point to normalize. |
Definition at line 673 of file RectTransformExtensions.cs.
|
static |
Normalizes a point associated with the parent object into "Anchor Space", which is to say, (0, 0) represents the parent's lower-left-hand corner, and (1, 1) represents the upper-right-hand.
point | The point to normalize. |
Definition at line 663 of file RectTransformExtensions.cs.
|
static |
Translates a point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner, into the same point relative to the RectTransform's current anchor.
x | X coordinate of the point to translate. |
y | Y coordinate of the point to translate. |
Definition at line 627 of file RectTransformExtensions.cs.
|
static |
Translates a point on the parent's frame of reference, with (0, 0) being the parent's lower-left hand corner, into the same point relative to the RectTransform's current anchor.
point | The point to translate. |
Definition at line 617 of file RectTransformExtensions.cs.
|
static |
Moves the edge to a distance towards the center from the same edge of the parent.
distance |
Definition at line 270 of file RectTransformExtensions.cs.
|
static |
Sets the normalized position in the parent RectTransform that the corners is anchored to.
Definition at line 66 of file RectTransformExtensions.cs.
|
static |
Sets the distance of the distance from the bottom edge to the parent's bottom edge regardless of the anchor position.
distance |
Definition at line 247 of file RectTransformExtensions.cs.
|
static |
Repositions the requested edge relative to the passed anchor.
anchor | The anchor to get the relative from. |
distance | The distance to be moved to. |
Definition at line 330 of file RectTransformExtensions.cs.
|
static |
Sets the height of the RectTransform keeping the current anchors.
Definition at line 119 of file RectTransformExtensions.cs.
|
static |
Sets the distance of the distance from the left edge to the parent's left edge regardless of the anchor position.
distance |
Definition at line 214 of file RectTransformExtensions.cs.
|
static |
Repositions the requested edge relative to the passed anchor.
anchor | The anchor to get the relative from. |
distance | The distance to be moved to. |
Definition at line 297 of file RectTransformExtensions.cs.
|
static |
Linearly interpolates between two RectTransforms.
When t = 0 returns a. When t = 1 returns b. When t = 0.5 returns the point midway between a and b.
Definition at line 795 of file RectTransformExtensions.cs.
|
static |
Sets the RectTransform position, rotation and scale to the same values in the given RectTransform.
properties | The RectTransform from which the position, rotation and scale will be copied. |
Definition at line 759 of file RectTransformExtensions.cs.
|
static |
Sets the transform properties to the given values.
anchoredPosition | The anchoredPosition to be set in the RectTransform. |
anchoredPosition3D | The anchoredPosition3D to be set in the RectTransform. |
anchorMax | The anchorMax to be set in the RectTransform. |
anchorMin | The anchorMin to be set in the RectTransform. |
offsetMax | The offsetMax to be set in the RectTransform. |
offsetMin | The offsetMin to be set in the RectTransform. |
pivot | The pivot to be set in the RectTransform. |
sizeDelta | The sizeDelta to be set in the RectTransform. |
trans | The transform to copy the scale and rotation from (and the position). |
Definition at line 777 of file RectTransformExtensions.cs.
|
static |
Moves the edge to the requested position relative to the current position.
Using these functions repeatedly will result in unintuitive behavior, since the anchored position is getting changed with each call.
rt | |
distance | The distance you to displace the bottom edge. |
Definition at line 375 of file RectTransformExtensions.cs.
|
static |
Moves the edge to the requested position relative to the current position.
Using these functions repeatedly will result in unintuitive behavior, since the anchored position is getting changed with each call.
rt | |
distance | The distance you to displace the left edge. |
Definition at line 345 of file RectTransformExtensions.cs.
|
static |
Moves the edge to the requested position relative to the current position.
Using these functions repeatedly will result in unintuitive behavior, since the anchored position is getting changed with each call.
rt | |
distance | The distance you to displace the right edge. |
Definition at line 355 of file RectTransformExtensions.cs.
|
static |
Moves the edge to the requested position relative to the current position.
Using these functions repeatedly will result in unintuitive behavior, since the anchored position is getting changed with each call.
rt | |
distance | The distance you to displace the top edge. |
Definition at line 365 of file RectTransformExtensions.cs.
|
static |
Sets the distance of the distance from the left edge to the parent's left edge regardless of the anchor position.
distance |
Definition at line 225 of file RectTransformExtensions.cs.
|
static |
Repositions the requested edge relative to the passed anchor.
anchor | The anchor to get the relative from. |
distance | The distance to be moved to. |
Definition at line 308 of file RectTransformExtensions.cs.
|
static |
Sets the width and the height of the RectTransform keeping the current anchors.
width | The desired width of the RectTransform |
height | The desired height of the RectTransform |
Definition at line 129 of file RectTransformExtensions.cs.
|
static |
Sets the width and the height of the RectTransform keeping the current anchors.
size | The desired width (x) and height (y) of the RectTransform. |
Definition at line 139 of file RectTransformExtensions.cs.
|
static |
Sets the distance of the distance from the top edge to the parent's top edge regardless of the anchor position.
distance |
Definition at line 236 of file RectTransformExtensions.cs.
|
static |
Repositions the requested edge relative to the passed anchor.
anchor | The anchor to get the relative from. |
distance | The distance to be moved to. |
Definition at line 319 of file RectTransformExtensions.cs.
|
static |
Sets the width of the RectTransform keeping the current anchors.
Definition at line 111 of file RectTransformExtensions.cs.
|
static |
Moves the edge to a distance towards the center from the same edge of the parent.
distance |
Definition at line 278 of file RectTransformExtensions.cs.