The position of the pivot of this RectTransform relative to the anchor reference point. | |
The 3D position of the pivot of this RectTransform relative to the anchor reference point. | |
The normalized position in the parent RectTransform that the upper right corner is anchored to. | |
The normalized position in the parent RectTransform that the lower left corner is anchored to. | |
The offset of the upper right corner of the rectangle relative to the upper right anchor. | |
The offset of the lower left corner of the rectangle relative to the lower left anchor. | |
The normalized position in this RectTransform that it rotates around. | |
The calculated rectangle in the local space of the Transform. | |
The size of this RectTransform relative to the distances between the anchors. |
-
anchor:连接Parent与Child的纽带。分为: anchor为点(即anchorMin == anchorMax),anchor为矩形框。
anchor为点:Pos相对于自身锚框的X和Y。 即相对于Parent位置固定(因此Parent大小变化不会导致自身位置变化,锚点保持和Parent元素的中心点位置不变。)anchor为框:即相对于Parent框的位置固定(因此Parent大小变化会导致自身发生变化,锚框根据Parent元素发生变化,保持相对Partent的元素的锚框比例发生不变)。
- Pivot 中心点:
- offsetMax; 矩形右上角(显示的元素)相对于右上角锚点(或锚框右上角)的偏移量。
- offsetMin; 矩形右上角(显示的元素)相对于左下角锚点(或锚框左上角)的偏移量。
- sizeDelta: RectTransform的大小相对于锚点之间的距离
- sizeDelta = offsetMax - offsetMin。使用代码中的offsetMax - offsetMax即可得出。
- 因此sizeDelta的含义也是变化的。
public Vector2 offsetMin
{
get
{
return anchoredPosition - Vector2.Scale(sizeDelta, pivot);
}
set
{
Vector2 offset = value - (anchoredPosition - Vector2.Scale(sizeDelta, pivot));
sizeDelta -= offset;
anchoredPosition += Vector2.Scale(offset, Vector2.one - pivot);
}
}
public Vector2 offsetMax
{
get
{
return anchoredPosition + Vector2.Scale(sizeDelta, Vector2.one - pivot);
}
set
{
Vector2 offset = value - (anchoredPosition + Vector2.Scale(sizeDelta, Vector2.one - pivot));
sizeDelta += offset;
anchoredPosition += Vector2.Scale(offset, pivot);
}
}
- anchoredPosition:Pivot 相对于锚点(或者是锚框中心点)的位置。