Ejemplo n.º 1
0
        public static void ChangePivot(this RectTransform self, LayoutPivotType layoutPivot)
        {
            Vector2 pivot = Vector2.one * 0.5f;

            switch (layoutPivot)
            {
            case LayoutPivotType.LeftTop:
                pivot = new Vector2(0, 1);
                break;

            case LayoutPivotType.LeftCenter:
                pivot = new Vector2(0, 0.5f);
                break;

            case LayoutPivotType.LeftBottom:
                pivot = new Vector2(0, 0);
                break;

            case LayoutPivotType.CenterTop:
                pivot = new Vector2(0.5f, 1);
                break;

            case LayoutPivotType.Center:
                pivot = new Vector2(0.5f, 0.5f);
                break;

            case LayoutPivotType.CenterBottom:
                pivot = new Vector2(0.5f, 0);
                break;

            case LayoutPivotType.RightTop:
                pivot = new Vector2(1, 1);
                break;

            case LayoutPivotType.RightCenter:
                pivot = new Vector2(1, 0.5f);
                break;

            case LayoutPivotType.RightBottom:
                pivot = new Vector2(1, 0);
                break;
            }
            ChangePivot(self, pivot);
        }
Ejemplo n.º 2
0
 public static void ChangeAnchorAndPivot(this RectTransform self, LayoutAnchorType layoutAnchorType, LayoutPivotType layoutPivotType)
 {
     ChangeAnchors(self, layoutAnchorType);
     ChangePivot(self, layoutPivotType);
 }