Ejemplo n.º 1
0
 protected void DrawTransform()
 {
     state = UIModifierUtils.DrawContentHeader("Transform", state);
     if (state)
     {
         UIModifierUtils.BeginContents(UIModifierUtils.DefaultContentColor);
         #region Sprie LocalPosition
         GUILayout.Space(3f);
         GUILayout.BeginHorizontal();
         bool reset = GUILayout.Button("P", GUILayout.Width(20f));
         EditorGUIUtility.labelWidth = 12;
         Trans.x = EditorGUILayout.FloatField("x", Trans.x, GUILayout.MinWidth(30f));
         Trans.y = EditorGUILayout.FloatField("y", Trans.y, GUILayout.MinWidth(30f));
         Trans.z = EditorGUILayout.FloatField("z", Trans.z, GUILayout.MinWidth(30f));
         EditorGUIUtility.labelWidth = 70;
         if (reset)
         {
             Trans.x = 0;
             Trans.y = 0;
             Trans.z = 0;
         }
         EditorGUIUtility.labelWidth = 70;
         GUILayout.EndHorizontal();
         #endregion
         UIModifierUtils.EndContents(UIModifierUtils.DefaultContentColor);
     }
 }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
0
    protected void DrawWidget()
    {
        state = UIModifierUtils.DrawContentHeader("Widget", state);
        if (state)
        {
            //GUILayout.Space(10f);
            UIModifierUtils.BeginContents(UIModifierUtils.DefaultContentColor);
            #region Pivot
            GUILayout.Space(3f);
            int newPivotH = PivotH, newPivotV = PivotV;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Pivot", GUILayout.Width(66f));
            if (GUILayout.Toggle(newPivotH == 0, "\u25C4", "ButtonLeft"))
            {
                newPivotH = 0;
            }
            if (GUILayout.Toggle(newPivotH == 1, "\u25AC", "ButtonMid"))
            {
                newPivotH = 1;
            }
            if (GUILayout.Toggle(newPivotH == 2, "\u25BA", "ButtonRight"))
            {
                newPivotH = 2;
            }
            if (GUILayout.Toggle(newPivotV == 0, "\u25B2", "ButtonLeft"))
            {
                newPivotV = 0;
            }
            if (GUILayout.Toggle(newPivotV == 1, "\u258C", "ButtonMid"))
            {
                newPivotV = 1;
            }
            if (GUILayout.Toggle(newPivotV == 2, "\u25BC", "ButtonRight"))
            {
                newPivotV = 2;
            }
            GUILayout.EndHorizontal();

            if (PivotH != newPivotH)
            {
                PivotH = newPivotH;
            }
            if (PivotV != newPivotV)
            {
                PivotV = newPivotV;
            }

            //if (GUILayout.Button("Change Pivot"))
            //{
            //	UIWidget.Pivot pivot = (UIWidget.Pivot)(3 * PivotV + PivotH);
            //	//Debug.Log(pivot.ToString());
            //	if (OnPivotChanged != null)
            //		OnPivotChanged(pivot);
            //}
            #endregion
            #region DrawDepth
            GUILayout.Space(3);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Depth", GUILayout.Width(66f));
            if (GUILayout.Button("Back", GUILayout.MinWidth(46f)))
            {
                Depth -= 1;
            }

            GUILayout.Space(5);
            int newDepth = EditorGUILayout.IntField("", Depth, GUILayout.MinWidth(50));
            if (newDepth != Depth)
            {
                Depth = newDepth;
            }
            GUILayout.Space(5);

            if (GUILayout.Button("Forward", GUILayout.MinWidth(60f)))
            {
                Depth += 1;
            }
            GUILayout.EndHorizontal();
            //if (GUILayout.Button("Change Depth"))
            //{
            //	//Debug.Log("Current Depth: " + Depth);
            //	if (OnDepthChanged != null)
            //		OnDepthChanged(Depth);
            //}
            #endregion
            #region DrawDimensions
            GUILayout.Space(3);
            GUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 70;
            Width = EditorGUILayout.IntField("Size", Width, GUILayout.MinWidth(30f));
            EditorGUIUtility.labelWidth = 12;
            Height = EditorGUILayout.IntField("x", Height, GUILayout.MinWidth(30f));
            EditorGUIUtility.labelWidth = 70;
            if (GUILayout.Button("Snap", GUILayout.Width(60f)))
            {
                if (OnSnap != null)
                {
                    OnSnap();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.IntField("Aspect", -1, GUILayout.MinWidth(30f));
                EditorGUILayout.EnumPopup(UIWidget.AspectRatioSource.Free);
                EditorGUI.EndDisabledGroup();
            }
            GUILayout.EndHorizontal();
            //if (GUILayout.Button("Change Dimensions"))
            //{
            //	//Debug.LogError("UNDONE: Change this button to toggle");
            //	if (OnDimensionsChanged != null)
            //		OnDimensionsChanged(Width, Height);
            //}
            #endregion
            #region DrawAspect
            //GUILayout.BeginHorizontal();
            //{
            //	EditorGUI.BeginDisabledGroup(true);
            //	EditorGUILayout.IntField("Aspect", -1, GUILayout.MinWidth(30f));
            //	EditorGUI.EndDisabledGroup();
            //}
            //GUILayout.EndHorizontal();
            #endregion
            UIModifierUtils.EndContents(UIModifierUtils.DefaultContentColor);
        }
    }