private void ShowFillOptions()
    {
        int length = (int)UISprite.FillDirection.Vertical + 1;

        string[] fillOptionNames  = new string[length];
        int[]    fillOptionValues = new int[length];
        string[] enumNames        = System.Enum.GetNames(typeof(UISprite.FillDirection));
        for (int i = 0; i < length; i++)
        {
            fillOptionNames[i]  = enumNames[i];
            fillOptionValues[i] = i;
        }

        int fillDirInt = serializedObject.FindProperty("mFillDirection").intValue;

        if (fillDirInt >= length)
        {
            fillDirInt = 0;
        }

        fillDirInt = EditorGUILayout.IntPopup("Fill Dir", fillDirInt, fillOptionNames, fillOptionValues);
        serializedObject.FindProperty("mFillDirection").intValue = fillDirInt;

        UISprite.FillDirection fillDir = (UISprite.FillDirection)fillDirInt;
        if (fillDir != UISprite.FillDirection.Nothing)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10f);
            GUILayout.BeginVertical();
            NGUIEditorTools.DrawProperty("Fill Amount", serializedObject, "mFillAmount", GUILayout.MinWidth(20f));
            NGUIEditorTools.DrawProperty("Invert Fill", serializedObject, "mInvert", GUILayout.MinWidth(20f));
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
    }
 void SetFillDirection(UISprite.FillDirection fillDirection, bool invertFill)
 {
     t.bar.fillDirection = fillDirection;
     t.bar.invert        = invertFill;
     if (t.effectBurnBar != null)
     {
         t.effectBurnBar.fillDirection = fillDirection;
         t.effectBurnBar.invert        = invertFill;
     }
 }
Esempio n. 3
0
    /// <summary>
    /// Sprites's custom properties based on the type.
    /// </summary>

    override protected void DrawExtraProperties()
    {
        NGUIEditorTools.DrawSeparator();

        if (GetType() == typeof(UISpriteInspector))
        {
            //GUILayout.BeginHorizontal();
            UISprite.Type type = (UISprite.Type)EditorGUILayout.EnumPopup("Sprite Type", mSprite.type);
            //GUILayout.Label("sprite", GUILayout.Width(58f));
            //GUILayout.EndHorizontal();

            if (mSprite.type != type)
            {
                NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
                mSprite.type = type;
                EditorUtility.SetDirty(mSprite.gameObject);
            }
        }

        if (mSprite.type == UISprite.Type.Sliced)
        {
            bool fill = EditorGUILayout.Toggle("Fill Center", mSprite.fillCenter);

            if (mSprite.fillCenter != fill)
            {
                NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
                mSprite.fillCenter = fill;
                EditorUtility.SetDirty(mSprite.gameObject);
            }
        }
        else if (mSprite.type == UISprite.Type.Filled)
        {
            if ((int)mSprite.fillDirection > (int)UISprite.FillDirection.Radial360)
            {
                mSprite.fillDirection = UISprite.FillDirection.Horizontal;
                EditorUtility.SetDirty(mSprite);
            }

            UISprite.FillDirection fillDirection = (UISprite.FillDirection)EditorGUILayout.EnumPopup("Fill Dir", mSprite.fillDirection);
            float fillAmount = EditorGUILayout.Slider("Fill Amount", mSprite.fillAmount, 0f, 1f);
            bool  invert     = EditorGUILayout.Toggle("Invert Fill", mSprite.invert);

            if (mSprite.fillDirection != fillDirection || mSprite.fillAmount != fillAmount || mSprite.invert != invert)
            {
                NGUIEditorTools.RegisterUndo("Sprite Change", mSprite);
                mSprite.fillDirection = fillDirection;
                mSprite.fillAmount    = fillAmount;
                mSprite.invert        = invert;
                EditorUtility.SetDirty(mSprite);
            }
        }
        GUILayout.Space(4f);
    }
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        NGUIEditorTools.SetLabelWidth(120f);

        TweenFillcount tw = target as TweenFillcount;

        GUI.changed = false;

        float from    = EditorGUILayout.FloatField("From", tw.from);
        float to      = EditorGUILayout.FloatField("To", tw.to);
        bool  bInvert = EditorGUILayout.Toggle("Invert Fill", tw.invertFill);

        UISprite.FillDirection fillDir = (UISprite.FillDirection)EditorGUILayout.EnumPopup("Fill Direction", tw.fillDir);

        if (from < 0)
        {
            from = 0;
        }
        if (to < 0)
        {
            to = 0;
        }

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Tween Change", tw);
            tw.from       = from;
            tw.to         = to;
            tw.invertFill = bInvert;
            tw.fillDir    = fillDir;
            tw.bInit      = false;
            UnityEditor.EditorUtility.SetDirty(tw);
        }

        DrawCommonProperties();
    }
    /// <summary>
    /// Draw all the custom properties such as sprite type, flip setting, fill direction, etc.
    /// </summary>

    protected override void DrawCustomProperties()
    {
        GUILayout.Space(6f);

        SerializedProperty sp = NGUIEditorTools.DrawProperty("Type", serializedObject, "mType", GUILayout.MinWidth(20f));

        UISprite.Type type = (UISprite.Type)sp.intValue;

        if (type == UISprite.Type.Simple || type == UISprite.Type.Sliced)
        {
            NGUIEditorTools.DrawBorderProperty("Trim", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Mirror", serializedObject, "mMirror");

            ShowFillOptions();

            EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
            {
                sp = serializedObject.FindProperty("centerType");
                bool val = (sp.intValue != (int)UISprite.AdvancedType.Invisible);

                if (val != EditorGUILayout.Toggle("Fill Center", val))
                {
                    sp.intValue = val ? (int)UISprite.AdvancedType.Invisible : (int)UISprite.AdvancedType.Sliced;
                }

                NGUIEditorTools.DrawProperty("Fill Border", serializedObject, "mFillBorder");
            }
            EditorGUI.EndDisabledGroup();
        }
        else if (type == UISprite.Type.Tiled)
        {
            NGUIEditorTools.DrawBorderProperty("Trim", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Mirror", serializedObject, "mMirror");
            NGUIEditorTools.DrawProperty("Tile Border", serializedObject, "mTileBorder");
        }
        else if (type == UISprite.Type.Filled)
        {
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Fill Dir", serializedObject, "mFillDirection", GUILayout.MinWidth(20f));
            UISprite.FillDirection fillDir = (UISprite.FillDirection)serializedObject.FindProperty("mFillDirection").intValue;
            if (fillDir != UISprite.FillDirection.Nothing)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10f);
                GUILayout.BeginVertical();
                NGUIEditorTools.DrawProperty("Fill Amount", serializedObject, "mFillAmount", GUILayout.MinWidth(20f));
                NGUIEditorTools.DrawProperty("Invert Fill", serializedObject, "mInvert", GUILayout.MinWidth(20f));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
        else if (type == UISprite.Type.Advanced)
        {
            SerializedProperty mirrorSp = serializedObject.FindProperty("mMirror");
            mirrorSp.intValue = (int)UISprite.Flip.Nothing;

            NGUIEditorTools.DrawBorderProperty("Border", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("  Left", serializedObject, "leftType");
            NGUIEditorTools.DrawProperty("  Right", serializedObject, "rightType");
            NGUIEditorTools.DrawProperty("  Top", serializedObject, "topType");
            NGUIEditorTools.DrawProperty("  Bottom", serializedObject, "bottomType");
            NGUIEditorTools.DrawProperty("  Center", serializedObject, "centerType");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
        }

        if (type == UIBasicSprite.Type.Simple || type == UIBasicSprite.Type.Sliced)         // Gradients get too complicated for tiled and filled.
        {
            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient", GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                serializedObject.DrawProperty("mGradientTop", "Top", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                serializedObject.DrawProperty("mGradientBottom", "Bottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        base.DrawCustomProperties();
    }
Esempio n. 6
0
    /// <summary>
    /// Draw all the custom properties such as sprite type, flip setting, fill direction, etc.
    /// </summary>

    protected override void DrawCustomProperties()
    {
        GUILayout.Space(6f);

        SerializedProperty sp = NGUIEditorTools.DrawProperty("Type", serializedObject, "mType", GUILayout.MinWidth(20f));

        NGUIEditorTools.DrawBorderProperty("Cut Down", serializedObject, "mCutDown");

        UISprite.Type type = (UISprite.Type)sp.intValue;

        if (type == UISprite.Type.Simple || type == UISprite.Type.Sliced)
        {
            NGUIEditorTools.DrawBorderProperty("Trim", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Mirror", serializedObject, "mMirror");

            ShowFillOptions();

            EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
            {
                sp = serializedObject.FindProperty("centerType");
                bool val = (sp.intValue != (int)UISprite.AdvancedType.Invisible);

                if (val != EditorGUILayout.Toggle("Fill Center", val))
                {
                    sp.intValue = val ? (int)UISprite.AdvancedType.Invisible : (int)UISprite.AdvancedType.Sliced;
                }

                NGUIEditorTools.DrawProperty("Fill Border", serializedObject, "mFillBorder");
            }
            EditorGUI.EndDisabledGroup();
        }
        else if (type == UISprite.Type.Tiled)
        {
            NGUIEditorTools.DrawBorderProperty("Trim", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Mirror", serializedObject, "mMirror");
            NGUIEditorTools.DrawProperty("Tile Border", serializedObject, "mTileBorder");
        }
        else if (type == UISprite.Type.Filled)
        {
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
            NGUIEditorTools.DrawProperty("Fill Dir", serializedObject, "mFillDirection", GUILayout.MinWidth(20f));
            UISprite.FillDirection fillDir = (UISprite.FillDirection)serializedObject.FindProperty("mFillDirection").intValue;
            if (fillDir != UISprite.FillDirection.Nothing)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10f);
                GUILayout.BeginVertical();
                NGUIEditorTools.DrawProperty("Fill Amount", serializedObject, "mFillAmount", GUILayout.MinWidth(20f));
                NGUIEditorTools.DrawProperty("Invert Fill", serializedObject, "mInvert", GUILayout.MinWidth(20f));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
        else if (type == UISprite.Type.Advanced)
        {
            NGUIEditorTools.DrawBorderProperty("Border", serializedObject, "mBorder");
            NGUIEditorTools.DrawProperty("  Left", serializedObject, "leftType");
            NGUIEditorTools.DrawProperty("  Right", serializedObject, "rightType");
            NGUIEditorTools.DrawProperty("  Top", serializedObject, "topType");
            NGUIEditorTools.DrawProperty("  Bottom", serializedObject, "bottomType");
            NGUIEditorTools.DrawProperty("  Center", serializedObject, "centerType");
            NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
        }

        //NGUIEditorTools.DrawProperty("Make Gray", serializedObject, "mGray");

        //GUI.changed = false;
        //Vector4 draw = EditorGUILayout.Vector4Field("Draw Region", mWidget.drawRegion);

        //if (GUI.changed)
        //{
        //    NGUIEditorTools.RegisterUndo("Draw Region", mWidget);
        //    mWidget.drawRegion = draw;
        //}
        base.DrawCustomProperties();
    }