Exemple #1
0
    /// <summary>
    /// Draw the inspector properties.
    /// </summary>

    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);
        EditorGUILayout.Space();

        serializedObject.Update();

        EditorGUI.BeginDisabledGroup(!ShouldDrawProperties());
        DrawCustomProperties();
        EditorGUI.EndDisabledGroup();
        DrawFinalProperties();
        UIRect.EnumSideType sideType = (UIRect.EnumSideType)EditorGUILayout.EnumPopup("SideType", SideType);
        if (SideType != sideType)
        {
            SideType = sideType;
            if (serializedObject.isEditingMultipleObjects)
            {
                foreach (var obj in targets)
                {
                    (obj as UIRect).SideType = SideType;
                }
            }
            else
            {
                (target as UIRect).SideType = SideType;
            }
        }


        serializedObject.ApplyModifiedProperties();
    }
Exemple #2
0
    /// <summary>
    /// Get the sides of the rectangle relative to the specified transform.
    /// The order is left, top, right, bottom.
    /// </summary>

    public override Vector3[] GetSides(Transform relativeTo, UIRect.EnumSideType SideType = UIRect.EnumSideType.AdaptTwoSide)
    {
        Vector2 offset = pivotOffset;

        float x0 = -offset.x * mWidth;
        float y0 = -offset.y * mHeight;
        float x1 = x0 + mWidth;
        float y1 = y0 + mHeight;
        float cx = (x0 + x1) * 0.5f;
        float cy = (y0 + y1) * 0.5f;

        Transform trans = cachedTransform;

        mCorners[0] = trans.TransformPoint(x0, cy, 0f);
        mCorners[1] = trans.TransformPoint(cx, y1, 0f);
        mCorners[2] = trans.TransformPoint(x1, cy, 0f);
        mCorners[3] = trans.TransformPoint(cx, y0, 0f);

        if (relativeTo != null)
        {
            for (int i = 0; i < 4; ++i)
            {
                mCorners[i] = relativeTo.InverseTransformPoint(mCorners[i]);
            }
        }
        return(mCorners);
    }
Exemple #3
0
    /// <summary>
    /// Determine the initial anchor type.
    /// </summary>

    protected virtual void OnEnable()
    {
        instance = this;

        if (serializedObject.isEditingMultipleObjects)
        {
            mAnchorType = AnchorType.Advanced;
            SideType    = UIRect.EnumSideType.AdaptTwoSide;
        }
        else
        {
            UIRect rect = target as UIRect;
            SideType = rect.SideType;
            ReEvaluateAnchorType();
        }
    }