Skip to content

RectTransform (JavaScript)

RectTransform

Scripting Name:Insight.RectTransform

GUI 的坐标变换。

Properties


anchoredPosition3D

type :Insight.Vector3

此 RectTransform 的枢轴点相对于锚点的 3D 位置。

anchoredPosition

type :Insight.Vector2

此 RectTransform 的枢轴点相对于锚点的 2D 位置。

rect

type :Insight.Vector4

(只读)该 RectTransform 的矩形框,四个分量分别是屏幕空间的位置(x, y)和长宽(width, height)。

anchorMax

type :Insight.Vector2

锚点的右上角在父物体的矩形框中的归一化 2D 坐标,(0,0)点在父物体的左下角。

anchorMin

type :Insight.Vector2

锚点的左下角在父物体的矩形框中的归一化 2D 坐标,(0,0)点在父物体的左下角。

pivot

type :Insight.Vector2

枢轴点在本地坐标系中的位置。

sizeDelta

type :Insight.Vector2

该 RectTransform 的实际长宽与锚点矩形的长宽的差值。

offsetMax

type :Insight.Vector2

该 UI 的矩形框的右上角相对于右上角锚点位置的差值。

offsetMin

type :Insight.Vector2

该 UI 的矩形框的左下角相对于左下角锚点位置的差值。

Methods


toString

javascript
public string toString();

将 rectTransform 内容以一定格式转为 string 类型。

javascript
// sample:
var rectTransform = Insight.GameObject.Find("Tip").getComponent("RectTransform", 0);Insight.Debug.Log(rectTransform.toString());

Inherited Properties(继承自 Component)


enabled

type : boolean

该组件是否是可用的。

gameObject

type : Insight.GameObject

(只读)该组件所依附的 GameObject。

isActiveAndEnabled

type : boolean

(只读)该组件是否可用,且其依附的 GameObject 是否是活跃状态。

name

type : string

(只读)所依附的 GameObject 的名称。

tag

type : string

(只读)所依附的 GameObject 的 Tag。

⚠️ 暂时未启用

transform

type : Insight.Transform

(只读)所依附的 GameObject 的 transform。