示例#1
1
 internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType groupType, int selectedIndex, System.Action<int, object> itemClickedCallback, GUIStyle guiStyle)
 {
   GameViewSizeGroup group = ScriptableSingleton<GameViewSizes>.instance.GetGroup(groupType);
   string t = selectedIndex < 0 || selectedIndex >= group.GetTotalCount() ? string.Empty : group.GetGameViewSize(selectedIndex).displayText;
   if (!EditorGUI.ButtonMouseDown(buttonRect, GUIContent.Temp(t), FocusType.Passive, guiStyle))
     return;
   FlexibleMenu flexibleMenu = new FlexibleMenu((IFlexibleMenuItemProvider) new GameViewSizesMenuItemProvider(groupType), selectedIndex, (FlexibleMenuModifyItemUI) new GameViewSizesMenuModifyItemUI(), itemClickedCallback);
   PopupWindow.Show(buttonRect, (PopupWindowContent) flexibleMenu);
 }
示例#2
0
            public static void Show(int itemIndex, FlexibleMenu caller)
            {
                FlexibleMenu.ItemContextMenu.s_Caller = caller;
                GenericMenu genericMenu = new GenericMenu();
                GenericMenu arg_3C_0    = genericMenu;
                GUIContent  arg_3C_1    = new GUIContent("Edit...");
                bool        arg_3C_2    = false;

                if (FlexibleMenu.ItemContextMenu.< > f__mg$cache0 == null)
                {
                    FlexibleMenu.ItemContextMenu.< > f__mg$cache0 = new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Edit);
                }
                arg_3C_0.AddItem(arg_3C_1, arg_3C_2, FlexibleMenu.ItemContextMenu.< > f__mg$cache0, itemIndex);
                GenericMenu arg_70_0 = genericMenu;
                GUIContent  arg_70_1 = new GUIContent("Delete");
                bool        arg_70_2 = false;

                if (FlexibleMenu.ItemContextMenu.< > f__mg$cache1 == null)
                {
                    FlexibleMenu.ItemContextMenu.< > f__mg$cache1 = new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Delete);
                }
                arg_70_0.AddItem(arg_70_1, arg_70_2, FlexibleMenu.ItemContextMenu.< > f__mg$cache1, itemIndex);
                genericMenu.ShowAsContext();
                GUIUtility.ExitGUI();
            }
示例#3
0
			public static void Show(int itemIndex, FlexibleMenu caller)
			{
				FlexibleMenu.ItemContextMenu.s_Caller = caller;
				GenericMenu genericMenu = new GenericMenu();
				genericMenu.AddItem(new GUIContent("Edit..."), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Edit), itemIndex);
				genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Delete), itemIndex);
				genericMenu.ShowAsContext();
				GUIUtility.ExitGUI();
			}
示例#4
0
            public static void Show(int itemIndex, FlexibleMenu caller)
            {
                FlexibleMenu.ItemContextMenu.s_Caller = caller;
                GenericMenu genericMenu = new GenericMenu();

                genericMenu.AddItem(new GUIContent("Edit..."), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Edit), itemIndex);
                genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction2(FlexibleMenu.ItemContextMenu.Delete), itemIndex);
                genericMenu.ShowAsContext();
                GUIUtility.ExitGUI();
            }
            static public void Show(int itemIndex, FlexibleMenu caller)
            {
                s_Caller = caller;
                GenericMenu menu = new GenericMenu();

                menu.AddItem(EditorGUIUtility.TrTextContent("Edit..."), false, Edit, itemIndex);
                menu.AddItem(EditorGUIUtility.TrTextContent("Delete"), false, Delete, itemIndex);
                menu.ShowAsContext();
                EditorGUIUtility.ExitGUI();
            }
示例#6
0
        public override void OnGUI(Rect rect)
        {
            if (GameViewSizesMenuModifyItemUI.s_Styles == null)
            {
                GameViewSizesMenuModifyItemUI.s_Styles = new GameViewSizesMenuModifyItemUI.Styles();
            }
            GameViewSize gameViewSize = this.m_Object as GameViewSize;

            if (gameViewSize == null)
            {
                Debug.LogError("Invalid object");
            }
            else
            {
                if (this.m_GameViewSize == null)
                {
                    this.m_GameViewSize = new GameViewSize(gameViewSize);
                }
                bool flag = this.m_GameViewSize.width > 0 && this.m_GameViewSize.height > 0;
                GUILayout.Space(3f);
                GUILayout.Label((this.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add) ? GameViewSizesMenuModifyItemUI.s_Styles.headerEdit : GameViewSizesMenuModifyItemUI.s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]);
                Rect rect2 = GUILayoutUtility.GetRect(1f, 1f);
                FlexibleMenu.DrawRect(rect2, (!EditorGUIUtility.isProSkin) ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                GUILayout.Space(4f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.optionalText, new GUILayoutOption[]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.typeName, new GUILayoutOption[]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, GameViewSizesMenuModifyItemUI.s_Styles.typeNames, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.widthHeightText, new GUILayoutOption[]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                float num       = 10f;
                float cropWidth = rect.width - 2f * num;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(num);
                GUILayout.FlexibleSpace();
                string text = this.m_GameViewSize.displayText;
                using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(text)))
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = "Result";
                    }
                    else
                    {
                        text = this.GetCroppedText(text, cropWidth, EditorStyles.label);
                    }
                    GUILayout.Label(GUIContent.Temp(text), EditorStyles.label, new GUILayoutOption[0]);
                }
                GUILayout.FlexibleSpace();
                GUILayout.Space(num);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(10f);
                if (GUILayout.Button(GameViewSizesMenuModifyItemUI.s_Styles.cancel, new GUILayoutOption[0]))
                {
                    base.editorWindow.Close();
                }
                using (new EditorGUI.DisabledScope(!flag))
                {
                    if (GUILayout.Button(GameViewSizesMenuModifyItemUI.s_Styles.ok, new GUILayoutOption[0]))
                    {
                        gameViewSize.Set(this.m_GameViewSize);
                        base.Accepted();
                        base.editorWindow.Close();
                    }
                }
                GUILayout.Space(10f);
                GUILayout.EndHorizontal();
            }
        }
示例#7
0
        public override void OnGUI(Rect rect)
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            Event current  = Event.current;
            Rect  viewRect = new Rect(0f, 0f, 1f, this.CalcSize().y);

            this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
            float num = 0f;

            for (int i = 0; i <= this.maxIndex; i++)
            {
                int  num2  = i + 1000000;
                Rect rect2 = new Rect(0f, num, rect.width, 18f);
                bool flag  = Array.IndexOf <int>(this.m_SeperatorIndices, i) >= 0;
                if (this.m_ShowAddNewPresetItem && i == this.m_ItemProvider.Count())
                {
                    this.CreateNewItemButton(rect2);
                }
                else
                {
                    if (this.m_ShowEditWindowForIndex == i)
                    {
                        this.m_ShowEditWindowForIndex = -1;
                        this.EditExistingItem(rect2, i);
                    }
                    EventType type = current.type;
                    switch (type)
                    {
                    case EventType.MouseDown:
                        if (current.button == 0 && rect2.Contains(current.mousePosition))
                        {
                            GUIUtility.hotControl = num2;
                            if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
                            {
                                GUIUtility.hotControl = 0;
                                this.SelectItem(i);
                                base.editorWindow.Close();
                                current.Use();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseUp:
                        if (GUIUtility.hotControl == num2)
                        {
                            GUIUtility.hotControl = 0;
                            if (current.button == 0 && rect2.Contains(current.mousePosition) && this.AllowDeleteClick(i))
                            {
                                this.DeleteItem(i);
                                current.Use();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseMove:
                        if (rect2.Contains(current.mousePosition))
                        {
                            if (this.m_HoverIndex != i)
                            {
                                this.m_HoverIndex = i;
                                this.Repaint();
                            }
                        }
                        else
                        {
                            if (this.m_HoverIndex == i)
                            {
                                this.m_HoverIndex = -1;
                                this.Repaint();
                            }
                        }
                        goto IL_389;

                    case EventType.MouseDrag:
                    case EventType.KeyDown:
                    case EventType.KeyUp:
                    case EventType.ScrollWheel:
IL_109:
                        if (type != EventType.ContextClick)
                        {
                            goto IL_389;
                        }
                        if (rect2.Contains(current.mousePosition))
                        {
                            current.Use();
                            if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(i))
                            {
                                FlexibleMenu.ItemContextMenu.Show(i, this);
                            }
                        }
                        goto IL_389;

                    case EventType.Repaint:
                    {
                        bool isHover = false;
                        if (this.m_HoverIndex == i)
                        {
                            if (rect2.Contains(current.mousePosition))
                            {
                                isHover = true;
                            }
                            else
                            {
                                this.m_HoverIndex = -1;
                            }
                        }
                        if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
                        {
                            isHover = (this.m_ItemProvider.GetItem(i) == this.m_ModifyItemUI.m_Object);
                        }
                        FlexibleMenu.s_Styles.menuItem.Draw(rect2, GUIContent.Temp(this.m_ItemProvider.GetName(i)), isHover, false, i == this.selectedIndex, false);
                        if (flag)
                        {
                            Rect rect3 = new Rect(rect2.x + 4f, rect2.y + rect2.height + 4f, rect2.width - 8f, 1f);
                            FlexibleMenu.DrawRect(rect3, (!EditorGUIUtility.isProSkin) ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                        }
                        if (this.AllowDeleteClick(i))
                        {
                            EditorGUIUtility.AddCursorRect(rect2, MouseCursor.ArrowMinus);
                        }
                        goto IL_389;
                    }
                    }
                    goto IL_109;
IL_389:
                    num += 18f;
                    if (flag)
                    {
                        num += 8f;
                    }
                }
            }
            GUI.EndScrollView();
        }
示例#8
0
        public override void OnGUI(Rect rect)
        {
            if (FlexibleMenu.s_Styles == null)
            {
                FlexibleMenu.s_Styles = new FlexibleMenu.Styles();
            }
            Event current  = Event.current;
            Rect  viewRect = new Rect(0.0f, 0.0f, 1f, this.CalcSize().y);

            this.m_ScrollPosition = GUI.BeginScrollView(rect, this.m_ScrollPosition, viewRect);
            float y = 0.0f;

            for (int index = 0; index <= this.maxIndex; ++index)
            {
                int  num   = index + 1000000;
                Rect rect1 = new Rect(0.0f, y, rect.width, 18f);
                bool flag  = Array.IndexOf <int>(this.m_SeperatorIndices, index) >= 0;
                if (this.m_ShowAddNewPresetItem && index == this.m_ItemProvider.Count())
                {
                    this.CreateNewItemButton(rect1);
                }
                else
                {
                    if (this.m_ShowEditWindowForIndex == index)
                    {
                        this.m_ShowEditWindowForIndex = -1;
                        this.EditExistingItem(rect1, index);
                    }
                    EventType type = current.type;
                    switch (type)
                    {
                    case EventType.MouseDown:
                        if (current.button == 0 && rect1.Contains(current.mousePosition))
                        {
                            GUIUtility.hotControl = num;
                            if (!this.IsDeleteModiferPressed() && current.clickCount == 1)
                            {
                                GUIUtility.hotControl = 0;
                                this.SelectItem(index);
                                this.editorWindow.Close();
                                current.Use();
                                break;
                            }
                            break;
                        }
                        break;

                    case EventType.MouseUp:
                        if (GUIUtility.hotControl == num)
                        {
                            GUIUtility.hotControl = 0;
                            if (current.button == 0 && rect1.Contains(current.mousePosition) && this.AllowDeleteClick(index))
                            {
                                this.DeleteItem(index);
                                current.Use();
                                break;
                            }
                            break;
                        }
                        break;

                    case EventType.MouseMove:
                        if (rect1.Contains(current.mousePosition))
                        {
                            if (this.m_HoverIndex != index)
                            {
                                this.m_HoverIndex = index;
                                this.Repaint();
                                break;
                            }
                            break;
                        }
                        if (this.m_HoverIndex == index)
                        {
                            this.m_HoverIndex = -1;
                            this.Repaint();
                            break;
                        }
                        break;

                    case EventType.Repaint:
                        bool isHover = false;
                        if (this.m_HoverIndex == index)
                        {
                            if (rect1.Contains(current.mousePosition))
                            {
                                isHover = true;
                            }
                            else
                            {
                                this.m_HoverIndex = -1;
                            }
                        }
                        if (this.m_ModifyItemUI != null && this.m_ModifyItemUI.IsShowing())
                        {
                            isHover = this.m_ItemProvider.GetItem(index) == this.m_ModifyItemUI.m_Object;
                        }
                        FlexibleMenu.s_Styles.menuItem.Draw(rect1, GUIContent.Temp(this.m_ItemProvider.GetName(index)), isHover, false, index == this.selectedIndex, false);
                        if (flag)
                        {
                            FlexibleMenu.DrawRect(new Rect(rect1.x + 4f, (float)((double)rect1.y + (double)rect1.height + 4.0), rect1.width - 8f, 1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                        }
                        if (this.AllowDeleteClick(index))
                        {
                            EditorGUIUtility.AddCursorRect(rect1, MouseCursor.ArrowMinus);
                            break;
                        }
                        break;

                    default:
                        if (type == EventType.ContextClick && rect1.Contains(current.mousePosition))
                        {
                            current.Use();
                            if (this.m_ModifyItemUI != null && this.m_ItemProvider.IsModificationAllowed(index))
                            {
                                FlexibleMenu.ItemContextMenu.Show(index, this);
                                break;
                            }
                            break;
                        }
                        break;
                    }
                    y += 18f;
                    if (flag)
                    {
                        y += 8f;
                    }
                }
            }
            GUI.EndScrollView();
        }
        public override void OnGUI(Rect rect)
        {
            if (GameViewSizesMenuModifyItemUI.s_Styles == null)
            {
                GameViewSizesMenuModifyItemUI.s_Styles = new GameViewSizesMenuModifyItemUI.Styles();
            }
            GameViewSize other = this.m_Object as GameViewSize;

            if (other == null)
            {
                Debug.LogError((object)"Invalid object");
            }
            else
            {
                if (this.m_GameViewSize == null)
                {
                    this.m_GameViewSize = new GameViewSize(other);
                }
                bool flag = this.m_GameViewSize.width > 0 && this.m_GameViewSize.height > 0;
                GUILayout.Space(3f);
                GUILayout.Label(this.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add ? GameViewSizesMenuModifyItemUI.s_Styles.headerEdit : GameViewSizesMenuModifyItemUI.s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]);
                FlexibleMenu.DrawRect(GUILayoutUtility.GetRect(1f, 1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                GUILayout.Space(4f);
                GUILayout.BeginHorizontal();
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.optionalText, new GUILayoutOption[1]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.typeName, new GUILayoutOption[1]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, GameViewSizesMenuModifyItemUI.s_Styles.typeNames);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(GameViewSizesMenuModifyItemUI.s_Styles.widthHeightText, new GUILayoutOption[1]
                {
                    GUILayout.Width(90f)
                });
                GUILayout.Space(10f);
                this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width);
                GUILayout.Space(5f);
                this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                float pixels    = 10f;
                float cropWidth = rect.width - 2f * pixels;
                GUILayout.BeginHorizontal();
                GUILayout.Space(pixels);
                GUILayout.FlexibleSpace();
                string displayText = this.m_GameViewSize.displayText;
                EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(displayText));
                GUILayout.Label(GUIContent.Temp(!string.IsNullOrEmpty(displayText) ? this.GetCroppedText(displayText, cropWidth, EditorStyles.label) : "Result"), EditorStyles.label, new GUILayoutOption[0]);
                EditorGUI.EndDisabledGroup();
                GUILayout.FlexibleSpace();
                GUILayout.Space(pixels);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(10f);
                if (GUILayout.Button(GameViewSizesMenuModifyItemUI.s_Styles.cancel))
                {
                    this.editorWindow.Close();
                }
                EditorGUI.BeginDisabledGroup(!flag);
                if (GUILayout.Button(GameViewSizesMenuModifyItemUI.s_Styles.ok))
                {
                    other.Set(this.m_GameViewSize);
                    this.Accepted();
                    this.editorWindow.Close();
                }
                EditorGUI.EndDisabledGroup();
                GUILayout.Space(10f);
                GUILayout.EndHorizontal();
            }
        }
        override public void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            GameViewSize gameViewSizeState = m_Object as GameViewSize;

            if (gameViewSizeState == null)
            {
                Debug.LogError("Invalid object");
                return;
            }

            // We use a local gameviewsize to ensure we do not edit the original state (if user presses cancel state is not changed)
            if (m_GameViewSize == null)
            {
                m_GameViewSize = new GameViewSize(gameViewSizeState);
            }

            bool        validSettings = m_GameViewSize.width > 0 && m_GameViewSize.height > 0;
            const float kColumnWidth  = 90f;
            const float kSpacing      = 10f;

            GUILayout.Space(3);
            GUILayout.Label(m_MenuType == MenuType.Add ? s_Styles.headerAdd : s_Styles.headerEdit,
                            EditorStyles.boldLabel);

            Rect seperatorRect = GUILayoutUtility.GetRect(1, 1);

            FlexibleMenu.DrawRect(seperatorRect,
                                  (EditorGUIUtility.isProSkin)
                ? new Color(0.32f, 0.32f, 0.32f, 1.333f)
                : new Color(0.6f, 0.6f, 0.6f, 1.333f));                      // dark : light
            GUILayout.Space(4);

            // Optional text
            GUILayout.BeginHorizontal();
            GUILayout.Label(s_Styles.optionalText, GUILayout.Width(kColumnWidth));
            GUILayout.Space(kSpacing);
            m_GameViewSize.baseText = EditorGUILayout.TextField(m_GameViewSize.baseText);
            GUILayout.EndHorizontal();

            // Drop list (aspect / fixed res)
            GUILayout.BeginHorizontal();
            GUILayout.Label(s_Styles.typeName, GUILayout.Width(kColumnWidth));
            GUILayout.Space(kSpacing);
            m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)m_GameViewSize.sizeType, s_Styles.typeNames);
            GUILayout.EndHorizontal();

            // Width Height
            GUILayout.BeginHorizontal();
            GUILayout.Label(s_Styles.widthHeightText, GUILayout.Width(kColumnWidth));
            GUILayout.Space(kSpacing);
            m_GameViewSize.width = EditorGUILayout.IntField(m_GameViewSize.width);
            GUILayout.Space(5);
            m_GameViewSize.height = EditorGUILayout.IntField(m_GameViewSize.height);
            GUILayout.EndHorizontal();

            GUILayout.Space(10f);

            // Displayed text
            float margin    = 10f;
            float cropWidth = rect.width - 2 * margin;

            GUILayout.BeginHorizontal();
            GUILayout.Space(margin);
            GUILayout.FlexibleSpace();
            string displayText = m_GameViewSize.displayText;

            using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(displayText)))
            {
                if (string.IsNullOrEmpty(displayText))
                {
                    displayText = "Result";
                }
                else
                {
                    displayText = GetCroppedText(displayText, cropWidth, EditorStyles.label);
                }
                GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label);
            }
            GUILayout.FlexibleSpace();
            GUILayout.Space(margin);
            GUILayout.EndHorizontal();

            GUILayout.Space(5f);

            // Cancel, Ok
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            if (GUILayout.Button(s_Styles.cancel))
            {
                editorWindow.Close();
            }

            using (new EditorGUI.DisabledScope(!validSettings))
            {
                if (GUILayout.Button(s_Styles.ok))
                {
                    gameViewSizeState.Set(m_GameViewSize);
                    Accepted();
                    editorWindow.Close();
                }
            }
            GUILayout.Space(10);
            GUILayout.EndHorizontal();
        }
示例#11
0
		internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType groupType, int selectedIndex, Action<int, object> itemClickedCallback, GUIStyle guiStyle)
		{
			GameViewSizeGroup group = ScriptableSingleton<GameViewSizes>.instance.GetGroup(groupType);
			string t;
			if (selectedIndex >= 0 && selectedIndex < group.GetTotalCount())
			{
				t = group.GetGameViewSize(selectedIndex).displayText;
			}
			else
			{
				t = string.Empty;
			}
			if (EditorGUI.ButtonMouseDown(buttonRect, GUIContent.Temp(t), FocusType.Passive, guiStyle))
			{
				IFlexibleMenuItemProvider itemProvider = new GameViewSizesMenuItemProvider(groupType);
				FlexibleMenu windowContent = new FlexibleMenu(itemProvider, selectedIndex, new GameViewSizesMenuModifyItemUI(), itemClickedCallback);
				PopupWindow.Show(buttonRect, windowContent);
			}
		}
示例#12
0
        public override void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            GameViewSize other = base.m_Object as GameViewSize;

            if (other == null)
            {
                Debug.LogError("Invalid object");
            }
            else
            {
                if (this.m_GameViewSize == null)
                {
                    this.m_GameViewSize = new GameViewSize(other);
                }
                bool flag = (this.m_GameViewSize.width > 0) && (this.m_GameViewSize.height > 0);
                GUILayout.Space(3f);
                GUILayout.Label((base.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add) ? s_Styles.headerEdit : s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]);
                FlexibleMenu.DrawRect(GUILayoutUtility.GetRect((float)1f, (float)1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                GUILayout.Space(4f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.optionalText, options);
                GUILayout.Space(10f);
                this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.typeName, optionArray2);
                GUILayout.Space(10f);
                this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, s_Styles.typeNames, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.widthHeightText, optionArray3);
                GUILayout.Space(10f);
                this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                float pixels    = 10f;
                float cropWidth = rect.width - (2f * pixels);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(pixels);
                GUILayout.FlexibleSpace();
                string displayText = this.m_GameViewSize.displayText;
                using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(displayText)))
                {
                    if (string.IsNullOrEmpty(displayText))
                    {
                        displayText = "Result";
                    }
                    else
                    {
                        displayText = this.GetCroppedText(displayText, cropWidth, EditorStyles.label);
                    }
                    GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label, new GUILayoutOption[0]);
                }
                GUILayout.FlexibleSpace();
                GUILayout.Space(pixels);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(10f);
                if (GUILayout.Button(s_Styles.cancel, new GUILayoutOption[0]))
                {
                    base.editorWindow.Close();
                }
                using (new EditorGUI.DisabledScope(!flag))
                {
                    if (GUILayout.Button(s_Styles.ok, new GUILayoutOption[0]))
                    {
                        other.Set(this.m_GameViewSize);
                        base.Accepted();
                        base.editorWindow.Close();
                    }
                }
                GUILayout.Space(10f);
                GUILayout.EndHorizontal();
            }
        }