private void DrawTypeFour()
    {
        if (GUILayout.Button("Get"))
        {
            left.floatValue   = _rectTransform.offsetMin.x;
            top.floatValue    = (-1) * _rectTransform.offsetMax.y;
            right.floatValue  = -_rectTransform.offsetMax.x;
            bottom.floatValue = _rectTransform.offsetMin.y;
        }

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

        EditorGUILayout.PropertyField(top, new GUIContent("Top"));
        GUILayout.Space(5);

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

        EditorGUILayout.PropertyField(bottom, new GUIContent("Bottom"));
        GUILayout.Space(5);

        if (GUILayout.Button("Use"))
        {
            RectTransformSetRect.SetStretchStretch(_rectTransform, left.floatValue, top.floatValue, right.floatValue, bottom.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);
        }
    }