public int Add(object obj) { GameViewSize gameViewSize = GameViewSizesMenuItemProvider.CastToGameViewSize(obj); if (gameViewSize == null) { return(-1); } this.m_GameViewSizeGroup.AddCustomSize(gameViewSize); ScriptableSingleton <GameViewSizes> .instance.SaveToHDD(); return(this.Count() - 1); }
internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType groupType, int selectedIndex, IGameViewSizeMenuUser gameView, GUIStyle guiStyle) { var group = GameViewSizes.instance.GetGroup(groupType); var text = ""; if (selectedIndex >= 0 && selectedIndex < group.GetTotalCount()) { text = group.GetGameViewSize(selectedIndex).displayText; } if (EditorGUI.DropdownButton(buttonRect, GUIContent.Temp(text), FocusType.Passive, guiStyle)) { var menuData = new GameViewSizesMenuItemProvider(groupType); var flexibleMenu = new GameViewSizeMenu(menuData, selectedIndex, new GameViewSizesMenuModifyItemUI(), gameView); PopupWindow.Show(buttonRect, flexibleMenu); } }
public void Replace(int index, object obj) { GameViewSize gameViewSize = GameViewSizesMenuItemProvider.CastToGameViewSize(obj); if (gameViewSize == null) { return; } if (index < this.m_GameViewSizeGroup.GetBuiltinCount()) { Debug.LogError("Only custom game view sizes can be changed"); return; } GameViewSize gameViewSize2 = this.m_GameViewSizeGroup.GetGameViewSize(index); if (gameViewSize2 != null) { gameViewSize2.Set(gameViewSize); ScriptableSingleton <GameViewSizes> .instance.SaveToHDD(); } }
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); } }