예제 #1
0
    /// <summary>
    /// Draw a sprite selection field.
    /// </summary>

    static public void SpriteField(string fieldName, string caption, UIAtlas atlas, string spriteName, SpriteSelector.Callback callback)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label(fieldName, GUILayout.Width(116f));

        if (atlas.GetSprite(spriteName) == null)
        {
            spriteName = "";
        }

        if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
        {
            NGUISettings.atlas          = atlas;
            NGUISettings.selectedSprite = spriteName;
            SpriteSelector.Show(callback);
        }

        if (!string.IsNullOrEmpty(caption))
        {
            GUILayout.Space(20f);
            GUILayout.Label(caption);
        }

        GUILayout.EndHorizontal();
        GUILayout.Space(-4f);
    }
예제 #2
0
    protected string EditSprite(UIAtlas atlas, string label, string sprite, SpriteSelector.Callback callback)
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label(label, GUILayout.Width(76f));

        string buttonLabel = sprite;

        if (string.IsNullOrEmpty(buttonLabel))
        {
            buttonLabel = "...";
        }

        if (GUILayout.Button(buttonLabel, itemSpriteOpt))
        {
            NGUISettings.atlas = atlas;
            SpriteSelector.Show(callback);
        }

        GUILayout.Space(12f);
        if (GUILayout.Button("None", itemSpriteDelOpt))
        {
            if (!string.IsNullOrEmpty(sprite))
            {
                RegisterUndo();
            }

            sprite = "";
        }
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(2f);

        return(sprite);
    }
    protected void ShouldDrawProperties(MeshBuilder mb)
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(76f)))
        {
            ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = serializedObject.FindProperty("mAtlas");

        EditorGUILayout.PropertyField(atlas, new GUIContent(""), GUILayout.MinWidth(20f));

        //mb.mAtlas = (UIAtlas)EditorGUILayout.ObjectField( "", mb.mAtlas, typeof(UIAtlas), true, GUILayout.MinWidth(20f) );
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Sprite", "DropDown", GUILayout.Width(76f)))
        {
            NGUISettings.atlas          = mb.mAtlas;
            NGUISettings.selectedSprite = mb.mSpriteName;
            SpriteSelector.Show(SelectSprite);
        }
        GUILayout.Label(mb.mSpriteName, "HelpBox", GUILayout.Height(18f));
        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        SerializedProperty sp = serializedObject.FindProperty("_Size");

        EditorGUILayout.PropertyField(sp);
    }
예제 #4
0
    /// <summary>
    /// Convenience function that displays a list of sprites and returns the selected value.
    /// </summary>

    static public void DrawAdvancedSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
                                               params GUILayoutOption[] options)
    {
        if (atlas == null)
        {
            return;
        }

        // Give the user a warning if there are no sprites in the atlas
        if (atlas.spriteList.Count == 0)
        {
            EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
            return;
        }

        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (NGUIEditorTools.DrawPrefixButton("Sprite"))
            {
                NGUISettings.atlas          = atlas;
                NGUISettings.selectedSprite = spriteName;
                SpriteSelector.Show(callback);
            }

            if (editable)
            {
                if (!string.Equals(spriteName, mLastSprite))
                {
                    mLastSprite = spriteName;
                    mEditedName = null;
                }

                string newName = GUILayout.TextField(string.IsNullOrEmpty(mEditedName) ? spriteName : mEditedName);

                if (newName != spriteName)
                {
                    mEditedName = newName;
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
                GUILayout.Space(18f);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                {
                    NGUISettings.atlas          = atlas;
                    NGUISettings.selectedSprite = spriteName;
                    Select(atlas.gameObject);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
예제 #5
0
    /// <summary>
    /// Draw a sprite selection field.
    /// </summary>

    static public void SpriteField(string fieldName, UIAtlas atlas, string spriteName,
                                   SpriteSelector.Callback callback, params GUILayoutOption[] options)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label(fieldName, GUILayout.Width(76f));

        if (GUILayout.Button(spriteName, "MiniPullDown", options))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
        }
        GUILayout.EndHorizontal();
    }
예제 #6
0
    /// <summary>
    /// Draw a simple sprite selection button.
    /// </summary>

    static public bool SimpleSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, params GUILayoutOption[] options)
    {
        if (atlas.GetSprite(spriteName) == null)
        {
            spriteName = "";
        }

        if (GUILayout.Button(spriteName, "DropDown", options))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
            return(true);
        }
        return(false);
    }
예제 #7
0
    /// <summary>
    /// Convenience function that displays a list of sprites and returns the selected value.
    /// </summary>

    static public void AdvancedSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
                                           params GUILayoutOption[] options)
    {
        // Give the user a warning if there are no sprites in the atlas
        if (atlas.spriteList.Count == 0)
        {
            EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
            return;
        }

        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
            {
                SpriteSelector.Show(atlas, spriteName, callback);
            }

            if (editable)
            {
                string sn = GUILayout.TextField(spriteName);

                if (sn != spriteName)
                {
                    UIAtlas.Sprite sp = atlas.GetSprite(spriteName);

                    if (sp != null)
                    {
                        NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
                        sp.name    = sn;
                        spriteName = sn;
                    }
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
                GUILayout.Space(18f);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                {
                    NGUISettings.selectedSprite = spriteName;
                    Select(atlas.gameObject);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
예제 #8
0
    /// <summary>
    /// Draw a sprite selection field.
    /// </summary>

    static public void SpriteField(string fieldName, string caption, UIAtlas atlas, string spriteName, SpriteSelector.Callback callback)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label(fieldName, GUILayout.Width(76f));

        if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
        }

        if (!string.IsNullOrEmpty(caption))
        {
            GUILayout.Space(20f);
            GUILayout.Label(caption);
        }
        GUILayout.EndHorizontal();
    }
예제 #9
0
    /// <summary>
    /// Convenience function that displays a list of sprites and returns the selected value.
    /// </summary>

    static public void AdvancedSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
                                           params GUILayoutOption[] options)
    {
        // Give the user a warning if there are no sprites in the atlas
        if (atlas.spriteList.Count == 0)
        {
            EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
            return;
        }

        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
            {
                SpriteSelector.Show(atlas, spriteName, callback);
            }

            if (editable)
            {
                if (!string.Equals(spriteName, mLastSprite))
                {
                    mLastSprite = spriteName;
                    mEditedName = null;
                }

                string newName = GUILayout.TextField(string.IsNullOrEmpty(mEditedName) ? spriteName : mEditedName);

                if (newName != spriteName)
                {
                    mEditedName = newName;

                    if (GUILayout.Button("Rename", GUILayout.Width(60f)))
                    {
                        UIAtlas.Sprite sprite = atlas.GetSprite(spriteName);

                        if (sprite != null)
                        {
                            NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
                            sprite.name = newName;

                            List <UISprite> sprites = FindAll <UISprite>();

                            for (int i = 0; i < sprites.Count; ++i)
                            {
                                UISprite sp = sprites[i];

                                if (sp.atlas == atlas && sp.spriteName == spriteName)
                                {
                                    NGUIEditorTools.RegisterUndo("Edit Sprite Name", sp);
                                    sp.spriteName = newName;
                                }
                            }

                            mLastSprite = newName;
                            spriteName  = newName;
                            mEditedName = null;

                            NGUISettings.selectedSprite = spriteName;
                        }
                    }
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
                GUILayout.Space(18f);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                {
                    NGUISettings.selectedSprite = spriteName;
                    Select(atlas.gameObject);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
예제 #10
0
    public override void DrawSubProperty()
    {
        state = UIModifierUtils.DrawContentHeader("UISprite", state);
        if (state)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(70)))
            {
                ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
            }
            EditorGUILayout.ObjectField(Atlas, typeof(UIFont), false);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Sprite", "DropDown", GUILayout.Width(70)))
            {
                NGUISettings.atlas          = Atlas;
                NGUISettings.selectedSprite = Sprite_Name;
                SpriteSelector.Show(SelectSprite);
            }
            GUILayout.Label(Sprite_Name, "HelpBox", GUILayout.Height(18f));
            GUILayout.Space(18f);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            {
                Flip_Type = (UIBasicSprite.Flip)EditorGUILayout.EnumPopup("Flip", Flip_Type);

                Sprite_Type = (UIBasicSprite.Type)EditorGUILayout.EnumPopup("Sprite Type", Sprite_Type);

                EditorGUI.indentLevel++;
                {
                    if (Sprite_Type == UISprite.Type.Simple)
                    {
                        GUILayout.BeginHorizontal();
                        Gradient = EditorGUILayout.Toggle("Gradient", Gradient, GUILayout.Width(80));
                        EditorGUI.BeginDisabledGroup(!Gradient);
                        {
                            EditorGUIUtility.labelWidth = 40;
                            Gradient_Top_Color          = EditorGUILayout.ColorField("Top", Gradient_Top_Color, GUILayout.MinWidth(60));
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label(" ", GUILayout.Width(80));
                            Gradient_Bottom_Color       = EditorGUILayout.ColorField("Bottom", Gradient_Bottom_Color, GUILayout.MinWidth(60));
                            EditorGUIUtility.labelWidth = 70;
                        }
                        EditorGUI.EndDisabledGroup();
                        GUILayout.EndHorizontal();
                    }
                    else if (Sprite_Type == UISprite.Type.Tiled)
                    {
                    }
                    else if (Sprite_Type == UISprite.Type.Sliced)
                    {
                        Fill_Center = EditorGUILayout.Toggle("Fill Center", Fill_Center);

                        GUILayout.BeginHorizontal();
                        Gradient = EditorGUILayout.Toggle("Gradient", Gradient, GUILayout.Width(80));
                        EditorGUI.BeginDisabledGroup(!Gradient);
                        {
                            Gradient_Top_Color = EditorGUILayout.ColorField("Top", Gradient_Top_Color, GUILayout.MinWidth(60));
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label(" ", GUILayout.Width(80));
                            Gradient_Bottom_Color = EditorGUILayout.ColorField("Bottom", Gradient_Bottom_Color, GUILayout.MinWidth(60));
                        }
                        EditorGUI.EndDisabledGroup();
                        GUILayout.EndHorizontal();
                    }
                    else if (Sprite_Type == UISprite.Type.Filled)
                    {
                        FillDirection_Type = (UIBasicSprite.FillDirection)EditorGUILayout.EnumPopup("Flip", FillDirection_Type, GUILayout.MinWidth(20f));
                        Fill_Amount        = EditorGUILayout.Slider("Amount", Fill_Amount, 0, 1f, GUILayout.MinWidth(20f));
                        Invert             = EditorGUILayout.Toggle("Invert", Invert);
                    }
                    else if (Sprite_Type == UISprite.Type.Advanced)
                    {
                        Left_Type   = (UIBasicSprite.AdvancedType)EditorGUILayout.EnumPopup("Left", Left_Type);
                        Right_Type  = (UIBasicSprite.AdvancedType)EditorGUILayout.EnumPopup("Right", Right_Type);
                        Bottom_Type = (UIBasicSprite.AdvancedType)EditorGUILayout.EnumPopup("Bottom", Bottom_Type);
                        Top_Type    = (UIBasicSprite.AdvancedType)EditorGUILayout.EnumPopup("Top", Top_Type);
                        Center_Type = (UIBasicSprite.AdvancedType)EditorGUILayout.EnumPopup("Center", Center_Type);;
                    }
                }
                EditorGUI.indentLevel--;
            }
            GUILayout.EndVertical();
            GUILayout.Space(18);
            GUILayout.EndHorizontal();
        }
    }
예제 #11
0
    private void DrewGUI(List <YuanPic> yuanPic, string listName, ComponentSelector.OnSelectionCallback callback, UIAtlas atlasCB)
    {
        if (NGUIEditorTools.DrawHeader(listName))
        {
            if (!dicOut.ContainsKey(listName))
            {
                dicOut.Add(listName, false);
            }
            atlasCB = (UIAtlas)EditorGUILayout.ObjectField(atlasCB, typeof(UIAtlas));
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(string.Format("{0}Atlas", listName)))
            {
                ComponentSelector.Show <UIAtlas>(callback);
            }
            GUILayout.Label(atlasCB != null ? atlasCB.name : "No Selected");
            EditorGUILayout.EndHorizontal();
            dicOut[listName] = EditorGUILayout.Foldout(dicOut[listName], listName);
            if (dicOut[listName])
            {
                int count = yuanPic.Count;

                count = EditorGUILayout.IntField("Size:", count);



                if (yuanPic.Count < count)
                {
                    int num = count - yuanPic.Count;
                    for (int i = 0; i < num; i++)
                    {
                        YuanPic tempYuanPic = new YuanPic();
                        yuanPic.Add(tempYuanPic);
                        tempYuanPic.atlas = atlasCB != null ? atlasCB : null;
                    }
                }
                else
                {
                    int num = yuanPic.Count - count;
                    for (int i = 0; i < num; i++)
                    {
                        yuanPic.RemoveAt(yuanPic.Count - 1);
                    }
                }

                int imageNum = 0;
                foreach (YuanPic item in yuanPic)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Image" + imageNum.ToString() + ":");

                    if (GUILayout.Button(item.atlas != null ? item.atlas.name : "Select Atlas"))
                    {
                        cbAtlas = item;
                        ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
                    }
                    if (item.atlas != null)
                    {
                        if (GUILayout.Button(item.spriteName != null ? item.spriteName : "Select Sprite"))
                        {
                            NGUISettings.atlas          = item.atlas;
                            NGUISettings.selectedSprite = item.spriteName;
                            SpriteSelector.Show(OnSelectSprite);
                            //                        SpriteSelector.Show(item.atlas, item.spriteName, OnSelectSprite);
                            cbSpriteName = item;
                        }
                    }
                    GUILayout.EndHorizontal();
                    imageNum++;
                }
            }
        }
    }
예제 #12
0
    public void DrawProperty()
    {
        UIModifierUtils.BeginContents(UIModifierUtils.DefaultContentColor);
        EditorGUILayout.HelpBox("进行UI替换前先执行下面按钮升级UIImageButton组件", MessageType.Error);
        GUILayout.Space(3);
        Color temp = GUI.color;

        GUI.color = Color.cyan;
        if (GUILayout.Button("AUTO-UPGRADE UIIMAGEBUTTON"))
        {
            if (OnUpdateClick != null)
            {
                OnUpdateClick();
            }
        }

        GUILayout.Space(20f);
        if (GUILayout.Button("RESET CONDITIONS"))
        {
            Reset();
        }
        GUILayout.Space(20f);
        GUI.color = temp;



        state = UIModifierUtils.DrawContentHeader("UIButton", state);
        if (state)
        {
            GUILayout.Space(3);
            EditorGUIUtility.labelWidth = 100;
            EnableColor = EditorGUILayout.Toggle("EnableColor", EnableColor);
            EditorGUIUtility.labelWidth = 70;
            EditorGUI.BeginDisabledGroup(!EnableColor);
            m_Color_Folder_State = EditorGUILayout.Foldout(m_Color_Folder_State, "Colors", true);
            if (m_Color_Folder_State)
            {
                EditorGUI.indentLevel++;
                Normal_Color   = EditorGUILayout.ColorField("Normal", Normal_Color);
                Hover_Color    = EditorGUILayout.ColorField("Hover", Hover_Color);
                Pressed_Color  = EditorGUILayout.ColorField("Pressed", Pressed_Color);
                Disabled_Color = EditorGUILayout.ColorField("Disabled", Disabled_Color);
                EditorGUI.indentLevel--;
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.Space(10);
            EditorGUIUtility.labelWidth = 100;
            EnableSprite = EditorGUILayout.Toggle("EnabelSprite", EnableSprite);
            EditorGUIUtility.labelWidth = 70;
            EditorGUI.BeginDisabledGroup(!EnableSprite);
            m_Sprite_Folder_State = EditorGUILayout.Foldout(m_Sprite_Folder_State, "Sprite", true);
            if (m_Sprite_Folder_State)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(70)))
                {
                    ComponentSelector.Show <UIAtlas>(OnSelectAtlas);
                }
                EditorGUILayout.ObjectField(Atlas, typeof(UIAtlas), false);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Normal", GUILayout.Width(70));
                if (GUILayout.Button(Normal_Sprite, "DropDown", GUILayout.MinWidth(70)))
                {
                    m_CurrentSelectSpriteIndex  = 1;
                    NGUISettings.atlas          = Atlas;
                    NGUISettings.selectedSprite = Normal_Sprite;
                    SpriteSelector.Show(SelectSprite);
                }
                GUILayout.Space(18);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Hover", GUILayout.Width(70));
                if (GUILayout.Button(Hover_Sprite, "DropDown", GUILayout.MinWidth(70)))
                {
                    m_CurrentSelectSpriteIndex  = 2;
                    NGUISettings.atlas          = Atlas;
                    NGUISettings.selectedSprite = Hover_Sprite;
                    SpriteSelector.Show(SelectSprite);
                }
                GUILayout.Space(18);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Press", GUILayout.Width(70));
                if (GUILayout.Button(Pressed_Sprite, "DropDown", GUILayout.MinWidth(70)))
                {
                    m_CurrentSelectSpriteIndex  = 3;
                    NGUISettings.atlas          = Atlas;
                    NGUISettings.selectedSprite = Pressed_Sprite;
                    SpriteSelector.Show(SelectSprite);
                }
                GUILayout.Space(18);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Disabled", GUILayout.Width(70));
                if (GUILayout.Button(Disabled_Sprite, "DropDown", GUILayout.MinWidth(70)))
                {
                    m_CurrentSelectSpriteIndex  = 4;
                    NGUISettings.atlas          = Atlas;
                    NGUISettings.selectedSprite = Disabled_Sprite;
                    SpriteSelector.Show(SelectSprite);
                }
                GUILayout.Space(18);
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(EnableSprite);
            m_Sprite2D_Folder_State = EditorGUILayout.Foldout(m_Sprite2D_Folder_State, "Sprite2D", true);
            if (m_Sprite2D_Folder_State)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Normal", GUILayout.Width(70));
                Normal_Sprite2D = (UnityEngine.Sprite)EditorGUILayout.ObjectField(Normal_Sprite2D, typeof(UnityEngine.Sprite), true);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Hover", GUILayout.Width(70));
                Hover_Sprite2D = (UnityEngine.Sprite)EditorGUILayout.ObjectField(Hover_Sprite2D, typeof(UnityEngine.Sprite), true);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Press", GUILayout.Width(70));
                Pressed_Sprite2D = (UnityEngine.Sprite)EditorGUILayout.ObjectField(Pressed_Sprite2D, typeof(UnityEngine.Sprite), true);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(18);
                GUILayout.Label("Disable", GUILayout.Width(70));
                Disabled_Sprite2D = (UnityEngine.Sprite)EditorGUILayout.ObjectField(Disabled_Sprite2D, typeof(UnityEngine.Sprite), true);
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();
        }

        GUILayout.Space(3);
        GUI.color = Color.cyan;
        if (GUILayout.Button("Modify All Properties", GUILayout.MinHeight(300)))
        {
            if (OnAllPropertiesChanged != null)
            {
                OnAllPropertiesChanged();
            }
        }
        GUI.color = temp;
        UIModifierUtils.EndContents(UIModifierUtils.DefaultContentColor);
    }
예제 #13
0
    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출                         */

    /* public - [Event] Function
     * 프랜드 객체가 호출                       */

    // ========================================================================== //

    /* protected - [abstract & virtual]         */

    /* protected - [Event] Function
     * 자식 객체가 호출                         */

    /* protected - Override & Unity API         */
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        _pTarget = target as CUIButtonMultiToggle;
        _pAtlas  = _pTarget.GetComponent <UISprite>().atlas;

        if (_pTarget.listEvent == null)
        {
            _pTarget.listEvent = new List <CUIButtonMultiToggle.SButtonToggle>();
        }

        _iOriginStateCount = _pTarget.listEvent.Count;
        _iOriginStateCount = EditorGUILayout.IntField("상태 개수", _iOriginStateCount);

        if (_pTarget.listEvent == null)
        {
            _pTarget.listEvent = new List <CUIButtonMultiToggle.SButtonToggle>();
        }

        if (_pAtlas == null)
        {
            Debug.LogWarning("UI Sprite의 Atlas가 세팅되지 않았습니다..", _pTarget);
            return;
        }

        if (_iOriginStateCount != _pTarget.listEvent.Count)
        {
            if (_iOriginStateCount < _pTarget.listEvent.Count)
            {
                int iLoopCount = _pTarget.listEvent.Count - _iOriginStateCount;
                try
                {
                    for (int i = 0; i < iLoopCount; i++)
                    {
                        _pTarget.listEvent.Remove(_pTarget.listEvent[i]);
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogWarning(e);
                }
            }
            else
            {
                int iLoopCount = _iOriginStateCount - _pTarget.listEvent.Count;
                for (int i = 0; i < iLoopCount; i++)
                {
                    _pTarget.listEvent.Add(new CUIButtonMultiToggle.SButtonToggle());
                }
            }
        }

        if (_iOriginStateCount != 0)
        {
            _pTarget.iDefaultState = EditorGUILayout.IntField(string.Format("기본 상태 1 ~ {0}", _pTarget.listEvent.Count), _pTarget.iDefaultState);
        }
        if (_pTarget.iDefaultState > _pTarget.listEvent.Count || _pTarget.iDefaultState <= 0)
        {
            Debug.LogError("상태개수 범위안의 숫자를 선택해 주십시오.");
        }

        _pTarget._eButtonToggleOption = (CUIButtonMultiToggle.EButtonToggleOption)EditorGUILayout.EnumPopup("옵션선택", _pTarget._eButtonToggleOption);

        for (int i = 0; i < _pTarget.listEvent.Count; i++)
        {
            CUIButtonMultiToggle.SButtonToggle sToggle = _pTarget.listEvent[i];
            //NGUIEditorTools.DrawEvents("On StateChange", _pTarget, sToggle.listEvent, false);

            if (NGUIEditorTools.DrawHeader(string.Format("OnChangeState_{0}", i + 1)) == false)
            {
                continue;
            }

            if (_pTarget.listEvent[i].listEvent == null)
            {
                _pTarget.listEvent[i].listEvent = new List <EventDelegate>();
            }

            EventDelegateEditor.Field(_pTarget, _pTarget.listEvent[i].listEvent, false);
            // 여기서 필요한 로직만 가져옴
            //NGUIEditorTools.DrawAdvancedSpriteField(_pAtlas, sToggle.strSpriteName, SelectSprite, false);
            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Sprite"))
                {
                    NGUISettings.atlas          = _pAtlas;
                    NGUISettings.selectedSprite = sToggle.strSpriteName;
                    SpriteSelector.Show(SelectSprite);
                    _iCurrentEditItemIndex = i;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(sToggle.strSpriteName, "HelpBox", GUILayout.Height(18f));
                NGUIEditorTools.DrawPadding();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndHorizontal();
        }
    }
예제 #14
0
    override protected bool OnDrawProperties()
    {
        UIParticle particle = mWidget as UIParticle;

        if (!base.OnDrawProperties())
        {
            return(false);
        }

        EditorGUILayout.BeginHorizontal();
        {
            particle.mUseFixedSeed = EditorGUILayout.Toggle("UseSeed:", particle.mUseFixedSeed, GUILayout.MinWidth(50f));
            particle.mFixedSeed    = EditorGUILayout.IntField("FixedSeed:", particle.mFixedSeed, GUILayout.MinWidth(150f));
        }
        EditorGUILayout.EndHorizontal();


        particle.mFollowDirection = EditorGUILayout.Toggle("Follow Direction:", particle.mFollowDirection);

        Vector2 start = EditorGUILayout.Vector2Field("Start Size:", particle.mStartSize);

        if (start != particle.mStartSize)
        {
            NGUIEditorTools.RegisterUndo("Undo ParticleSize", particle);
            particle.mStartSize = start;
        }
        Vector2 end = EditorGUILayout.Vector2Field("End Size:", particle.mEndSize);

        if (end != particle.mEndSize)
        {
            NGUIEditorTools.RegisterUndo("Undo ParticleSize", particle);
            particle.mEndSize = end;
        }

        particle.mSizeCurve = EditorGUILayout.CurveField("Size Curve", particle.mSizeCurve, Color.green, new Rect(0.0f, 0.0f, 1.0f, 1.0f));

        SerializedObject   serializedObj  = new SerializedObject(particle);
        SerializedProperty serializedProp = serializedObj.FindProperty("mColorGradient");

        EditorGUILayout.PropertyField(serializedProp, new GUIContent("Color"));

        serializedObj.ApplyModifiedProperties();

        mShowAniamtions = EditorGUILayout.Foldout(mShowAniamtions, "Aniamtions");
        if (mShowAniamtions == true)
        {
            int size = EditorGUILayout.IntField("size", particle.Animations.Length);
            if (size != particle.Animations.Length)
            {
                particle.mHasInitUVs = false;
                int      newsize = Mathf.Min(size, particle.Animations.Length);
                string[] buf     = new string[size];
                for (int i = 0; i < newsize; i++)
                {
                    buf[i] = particle.Animations[i];
                }
                particle.Animations = buf;
            }
            for (int i = 0; i < particle.Animations.Length; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Sprite") == true)
                {
                    mIndex = i;
                    SpriteSelector.Show(AnimationIdxCallBack);
                }
                //particle.Animations[i] = EditorGUILayout.TextField(particle.Animations[i]);
                string name = EditorGUILayout.TextField(particle.Animations[i]);
                if (name != particle.Animations[i])
                {
                    particle.Animations[i] = name;
                    particle.mHasInitUVs   = false;
                }
                EditorGUILayout.EndHorizontal();
            }
        }

        particle.Loop             = EditorGUILayout.IntField("Loop", particle.Loop);
        particle.mUseParticleSize = EditorGUILayout.Toggle("Use Size", particle.mUseParticleSize);
        return(true);
    }
예제 #15
0
    protected void EditMenuItem(CtxMenu.Item item, UIAtlas atlas)
    {
        if (item == null)
        {
            return;
        }

        GUILayoutOption[] itemSpriteOpt    = { GUILayout.Height(16f), GUILayout.Width(140f) };
        GUILayoutOption[] itemSpriteDelOpt = { GUILayout.Height(16f), GUILayout.Width(60f) };

        Color normalColor, disabledColor;

        Rect box = EditorGUILayout.BeginVertical();

        GUILayout.Space(4f);
        GUI.Box(box, "");

        EditorGUILayout.BeginHorizontal();
        item.isSelected = EditorGUILayout.Toggle(item.isSelected, GUILayout.Width(12f));

        EditorGUIUtility.labelWidth = 64f;
        CtxMenu.ItemStyle itemStyle = (CtxMenu.ItemStyle)EditorGUILayout.EnumFlagsField("Style", item.style,
                                                                                        GUILayout.Width(188f));

        if (item.style != itemStyle)
        {
            RegisterUndo();

            bool wasSubmenu = item.isSubmenu;

            item.style = itemStyle;

            if (item.isSubmenu && !wasSubmenu)
            {
                item.id = -1;
            }
        }

        if (item.isCheckable)
        {
            EditorGUIUtility.labelWidth = 44f;
            int mutexGroup = EditorGUILayout.IntField("Mutex", item.mutexGroup, GUILayout.Width(88f));
            if (mutexGroup != item.mutexGroup)
            {
                RegisterUndo();
                item.mutexGroup = mutexGroup;
            }
        }

        EditorGUIUtility.labelWidth = 80f;
        EditorGUILayout.EndHorizontal();

        if ((item.style & CtxMenu.ItemStyle.Separator) != (CtxMenu.ItemStyle) 0)
        {
            item.id = -1;
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            string text = EditorGUILayout.TextField("    Text", item.text, GUILayout.Width(204f));
            if (item.text != text)
            {
                RegisterUndo();
                item.text = text;
            }

            EditorGUIUtility.labelWidth = 32f;
            GUILayout.Space(12f);
            int itemId = EditorGUILayout.IntField("ID", item.id, GUILayout.Width(76f));
            if (item.id != itemId)
            {
                RegisterUndo();
                item.id = itemId;
            }
            EditorGUIUtility.labelWidth = 80f;

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("    Icon", GUILayout.Width(76f));

            string iconTitle = item.icon;
            if (string.IsNullOrEmpty(iconTitle))
            {
                iconTitle = "...";
            }

            if (GUILayout.Button(iconTitle, itemSpriteOpt))
            {
                currentItem        = item;
                NGUISettings.atlas = atlas;
                SpriteSelector.Show(OnItemIcon);
            }

            GUILayout.Space(12f);
            if (GUILayout.Button("None", itemSpriteDelOpt))
            {
                if (!string.IsNullOrEmpty(item.icon))
                {
                    RegisterUndo();
                }

                item.icon = "";
            }

            EditorGUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(item.icon))
            {
                EditorGUILayout.BeginHorizontal();
                normalColor = EditorGUILayout.ColorField("    Normal", item.spriteColor, GUILayout.Width(140f));
                if (normalColor != item.spriteColor)
                {
                    RegisterUndo();
                    item.spriteColor = normalColor;
                }
                GUILayout.Space(32f);
                disabledColor = EditorGUILayout.ColorField("Disabled", item.spriteColorDisabled, GUILayout.Width(140f));
                if (item.spriteColorDisabled != disabledColor)
                {
                    RegisterUndo();
                    item.spriteColorDisabled = disabledColor;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (item.isSubmenu)
            {
                CtxMenu submenu = (CtxMenu)EditorGUILayout.ObjectField("    Submenu", item.submenu, typeof(CtxMenu), true, GUILayout.Width(317f));
                if (item.submenu != submenu)
                {
                    RegisterUndo();
                    item.submenu = submenu;

#if CTX_NO_SERIALIZATION_FIX
                    if (submenu.items == null || submenu.items.Length == 0)
                    {
                        Debug.Log("Wizzy Submenu Item Transfer Test!!!!");

                        if (item.submenuItems != null && item.submenuItems.Length > 0)
                        {
                            Debug.Log("Wizzy Submenu Item Transfer!!!!");
                            submenu.items     = item.submenuItems;
                            item.submenuItems = null;

                            EditorUtility.SetDirty(submenu);
                            EditorUtility.SetDirty(target);
                        }
                    }
#endif
                }

                if (submenu != null)
#if CTX_NO_SERIALIZATION_FIX
                { EditMenuItemList(ref item.submenuItems, submenu.atlas, false, ref item.isEditingItems); }
#else
                { EditMenuItemList(ref submenu.items, submenu.atlas, false, ref item.isEditingItems); }
#endif
            }
        }

        GUILayout.Space(4f);
        EditorGUILayout.EndVertical();
        GUILayout.Space(4f);
    }