Protected
constructorThe anchor rect positioning this ScreenTransform proportional to its parent's bounds.
For each field, a value of 0
equals the parent's center point, and value of -1
or 1
(depending on the side) equals the parent's full boundary.
For example, a top
value of 1.0
means this ScreenTransform's top edge will be exactly at the top edge of its parent.
A bottom
value of -0.5
means this ScreenTransform's bottom edge will be halfway between its parent's bottom edge and center.
A right
value of 0
means this ScreenTransform's right edge will be exactly at its parent's center.
A left
value of -2
means this ScreenTransform's left edge will be twice as far from its parent's center as its parent's left edge is.
If disabled, the Component will stop enacting its behavior.
Display the debug view of the screen transform.
This rect is applied after anchors
to determine the final boundaries of the ScreenTransform.
It adds an offset in world units (based on the parent Camera's to each edge of the ScreenTransform's boundaries.
For example, a value of 0
for any side will have no effect on boundaries.
A value of 1.0
for any side will offset that edge by 1.0
world unit.
Normalized (x, y) position of the center point used in rotation. (-1, -1) being bottom left, (0, 0) being center, and (1, 1) being top right of the image.
Basic local position in world units relative to the parent's center. Useful for animating screen elements with a simple offset.
Basic local rotation applied to the SceneObject.
Basic local scaling applied to the SceneObject.
Readonly
sceneThe scene object this component is on.
Readonly
uniqueReturns true if the local point is within the boundaries of this ScreenTransform--that is: its position is within -1
and 1
in both the x and y coordinates.
Returns true if the screen position is within the boundaries of this ScreenTransform. Useful for checking if a touch event overlaps with this object. This function will calculate the ScreenPoint by heuristically looking for a camera: first checking for a camera in it's parent's hierarchy, then looking for a camera with the same render layer, and finally just choosing the first camera in the scene.
Returns true if the world position is within the boundaries of this ScreenTransform.
The z
value of the world position is ignored.
Destroys the component.
Returns the SceneObject the component is attached to.
Returns the Transform this component is attached to.
Returns the name of this object's type.
Returns true if this ScreenTransform is in a valid screen hierarchy, which is required for anchoring to work. To be in a valid screen hierarchy there must be a Camera component upward in the parent hierarchy, and every object between the Camera and this one must also have a ScreenTransform.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other
. Useful for checking if two references point to the same thing.
Converts from a normalized (-1 to 1) position within this ScreenTransform's bounds to a screen position. This function will calculate the ScreenPoint by heuristically looking for a camera: first checking for a camera in it's parent's hierarchy, then looking for a camera with the same render layer, and finally just choosing the first camera in the scene.
Used for positioning objects in 2D screen space. Modifies the position, size, and anchoring of a rectangle relatively to a parent ScreenTransform.
Remarks
It overrides the regular Transform component on the SceneObject it's attached to.
See
Screen Transform guide.
Example