private void HandleUpdate() { if (inputDevice_.Action4.WasPressed) { ScrollableMenuPopup.Show(inputDevice_, populators_.SelectMany(p => p.GetItems())); } }
// PRAGMA MARK - Public Interface public static void CreateMenu(Type attributeType, AttributeData attribute, Action callback) { if (!menuItemFactoryMap_.ContainsKey(attributeType)) { Debug.LogWarning("Cannot create menu for attributeType: " + attributeType + " skipping!"); callback.Invoke(); } var menuItemFactory = menuItemFactoryMap_[attributeType]; var menuItems = menuItemFactory.Invoke(attribute, callback); ScrollableMenuPopup.Show(LevelEditor.InputDevice, menuItems); }
// PRAGMA MARK - IScrollableMenuPopulator Implementation List <ScrollableMenuItem> IScrollableMenuPopulator.GetItems() { var items = new List <ScrollableMenuItem>(); items.Add(new ScrollableMenuItem(thumbnail: null, name: "SpawnPoint", callback: () => { var spawnPointItems = new List <ScrollableMenuItem>(); for (int i = 0; i < 4; i++) { int playerIndex = i; spawnPointItems.Add(new ScrollableMenuItem(thumbnail: null, name: "Player" + playerIndex, callback: () => { levelEditor_.SetObjectToPlace(GamePrefabs.Instance.LevelEditorPlayerSpawnPointPrefab, (GameObject g) => { g.GetComponent <LevelEditorPlayerSpawnPoint>().SetPlayerIndex(playerIndex); }); })); } ScrollableMenuPopup.Show(inputDevice_, spawnPointItems); })); return(items); }