Exemplo n.º 1
0
 private void HandleUpdate()
 {
     if (inputDevice_.Action4.WasPressed)
     {
         ScrollableMenuPopup.Show(inputDevice_, populators_.SelectMany(p => p.GetItems()));
     }
 }
Exemplo n.º 2
0
        public void Dispose()
        {
            MonoBehaviourWrapper.OnUpdate -= HandleUpdate;
            ScrollableMenuPopup.Hide();

            foreach (var populator in populators_)
            {
                populator.Dispose();
            }
        }
        // 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);
        }
 void IScrollableMenuPopulator.Dispose()
 {
     ScrollableMenuPopup.Hide();
 }