コード例 #1
0
    public void ShowItemLevels(ItemDefinition definition, Vector3 position)
    {
        HideItemLevels();
        int count = definition.levels.Count;

        Add(_itemLevels = new Layout("ItemLevels", 4, count + 1, 0.25f, 0.1f, count + 1, container));
        _itemLevels.SetPosition(position + (Vector3.right * _itemLevels.width * 0.5f) + (Vector3.back * _itemLevels.height * 0.5f));

        _itemLevels.Add(new List <Button>(
                            Button.GetButtons(count,
                                              (int index) => new Button("Level " + index, 3, 1, container, "Item", fontSize: 20,
                                                                        Enter: (Button button) => button.SetColor(button.selected ? button.color : Color.green),
                                                                        Stay: (Button button) =>
        {
            if (Input.GetMouseButtonDown(0))
            {
                _selectedItem  = definition;
                _selectedLevel = index;
                ShowItemEditor();
                HideItemLevels();
            }
        },
                                                                        Exit: (Button button) => button.SetColor(button.selected ? button.color : Color.white))))
        {
            new Button("Add Item Level", 4, 1, container, "AddItemLevel", fontSize: 20,
                       Enter: ( Button button ) => button.SetColor(Color.green),
                       Stay: ( Button button ) =>
            {
                if (Input.GetMouseButtonDown(0))
                {
                    definition.AddLevel();
                    ShowItemLevels(definition, position);
                }
            },
                       Exit: ( Button button ) => button.SetColor(Color.white))
        }, true);
    }