Ejemplo n.º 1
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);
        }
    }
Ejemplo n.º 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);
        }
    }