private void DrawTypeTwo()
    {
        if (GUILayout.Button("Get"))
        {
            left.floatValue = _rectTransform.offsetMin.x;
            posY.floatValue = _rectTransform.anchoredPosition.y;

            right.floatValue = -_rectTransform.offsetMax.x;

            height.floatValue = _rectTransform.rect.height;
        }

        GUILayout.Space(5);
        EditorGUILayout.PropertyField(left, new GUIContent("Left"));
        GUILayout.Space(5);

        EditorGUILayout.PropertyField(posY, new GUIContent("PosY"));
        GUILayout.Space(5);

        EditorGUILayout.PropertyField(right, new GUIContent("Right"));
        GUILayout.Space(5);

        EditorGUILayout.PropertyField(height, new GUIContent("Height"));
        GUILayout.Space(5);

        if (GUILayout.Button("Use"))
        {
            RectTransformSetRect.SetStretchBottomMiddleTop(_rectTransform, left.floatValue, right.floatValue, posY.floatValue, height.floatValue);
        }
    }
Beispiel #2
0
    void Start()
    {
        if (!enableUse)
        {
            return;
        }

        _rectTransform = GetComponent <RectTransform> ();
        if (_rectTransform == null)
        {
            return;
        }

        if ((int)anchorsType >= (int)ANCHORSTYPE.TOP_LEFT && (int)anchorsType <= (int)ANCHORSTYPE.BOTTOM_RIGHT)
        {
            RectTransformSetRect.SetLeftMiddleRight(_rectTransform, posX, posY, width, height);
        }
        else if ((int)anchorsType <= (int)ANCHORSTYPE.BOTTOM_STRETCH)
        {
            RectTransformSetRect.SetStretchBottomMiddleTop(_rectTransform, left, right, posY, height);
        }
        else if ((int)anchorsType <= (int)ANCHORSTYPE.STRETCH_RIGHT)
        {
            RectTransformSetRect.SetStretchLeftCenterRight(_rectTransform, posX, top, width, bottom);
        }
        else if ((int)anchorsType <= (int)ANCHORSTYPE.STRETCH_STRETCH)
        {
            RectTransformSetRect.SetStretchStretch(_rectTransform, left, top, right, bottom);
        }
    }