UnityEngine.RectTransform.SetSizeWithCurrentAnchors C# (CSharp) Method

SetSizeWithCurrentAnchors() public method

public SetSizeWithCurrentAnchors ( Axis axis, float size ) : void
axis Axis
size float
return void
        public void SetSizeWithCurrentAnchors(Axis axis, float size)
        {
            int num = (int) axis;
            Vector2 sizeDelta = this.sizeDelta;
            sizeDelta[num] = size - (this.GetParentSize()[num] * (this.anchorMax[num] - this.anchorMin[num]));
            this.sizeDelta = sizeDelta;
        }

Usage Example

コード例 #1
2
ファイル: CanvasLine.cs プロジェクト: inoook/uGUICanvasTools
    public static void DrawLine(Vector3 pos0, Vector3 pos1, RectTransform rectTrans, float thickness)
    {
        // drawLine
        float dist = Vector3.Distance(pos0, pos1);

        rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, dist);
        rectTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, thickness);

        rectTrans.pivot = new Vector2(0, 0.5f); // update pivot

        Vector3 dir = pos1 - pos0;
        float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        rectTrans.eulerAngles = new Vector3(0,0, angle);

        rectTrans.anchoredPosition = pos0;
    }
All Usage Examples Of UnityEngine.RectTransform::SetSizeWithCurrentAnchors