Exemplo n.º 1
0
    private void DrawTypeOne()
    {
        if (GUILayout.Button("Get"))
        {
            posX.floatValue = _rectTransform.anchoredPosition.x;
            posY.floatValue = _rectTransform.anchoredPosition.y;

            width.floatValue  = _rectTransform.rect.width;
            height.floatValue = _rectTransform.rect.height;
        }

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

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

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

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

        if (GUILayout.Button("Use"))
        {
            RectTransformSetRect.SetLeftMiddleRight(_rectTransform, posX.floatValue, posY.floatValue, width.floatValue, height.floatValue);
        }
    }
Exemplo n.º 2
0
    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);
        }
    }
Exemplo n.º 3
0
    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);
        }
    }
Exemplo n.º 4
0
    public void DrawTypeThree()
    {
        if (GUILayout.Button("Get"))
        {
            posX.floatValue   = _rectTransform.anchoredPosition.x;
            top.floatValue    = _rectTransform.offsetMax.y;
            width.floatValue  = _rectTransform.rect.width;
            bottom.floatValue = _rectTransform.offsetMin.y;
        }

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

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

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

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

        if (GUILayout.Button("Use"))
        {
            RectTransformSetRect.SetStretchLeftCenterRight(_rectTransform, posX.floatValue, top.floatValue, width.floatValue, bottom.floatValue);
        }
    }
Exemplo n.º 5
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);
        }
    }