コード例 #1
0
    private void GenerateCellsMatrix()
    {
        EquipmentLayout equip = (EquipmentLayout)target;
        int             cols  = equip.Cols;
        int             rows  = equip.Rows;

        EditorUtils.Header("Grid");
        GUILayoutOption[] options = new GUILayoutOption[]
        {
            GUILayout.Width(30),
            GUILayout.Height(30)
        };
        if (!equip.CheckLayout())
        {
            EquipmentNotCompleteAlert();
        }

        for (int j = 0; j < rows; j++)
        {
            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < cols; i++)
            {
                CellState state          = equip.GetState(i, j);
                string    buttonName     = EquipmentEditorUtils.GetCellButtonText(state);
                bool      isSelectedCell = _selectedCellPos.x == i && _selectedCellPos.y == j;
                if (isSelectedCell)
                {
                    GUI.backgroundColor = _selectedCellColor;
                }
                if (GUILayout.Button(buttonName, options))
                {
                    if (!isSelectedCell)
                    {
                        _selectedCellPos = new Vector2Int(i, j);
                    }
                    else
                    {
                        _selectedCellPos = _noSelectedCellPos;
                    }
                }
                if (isSelectedCell)
                {
                    GUI.backgroundColor = Color.white;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorUtility.SetDirty(equip);
    }
コード例 #2
0
    private void GenerateSelectedCellInfo()
    {
        EquipmentLayout equip = (EquipmentLayout)target;
        int             x     = _selectedCellPos.x;
        int             y     = _selectedCellPos.y;

        if (_selectedCellPos.x != -1)
        {
            EditorUtils.Header("Cell Info");
            EditorGUI.indentLevel++;
            CellState tmpState = (CellState)EditorGUILayout.EnumPopup("State", equip.GetState(x, y), _typeEnumDropdownOptions);
            equip.SetState(x, y, tmpState);
            Cell cell    = equip.GetCell(x, y);
            Cell tmpCell = (Cell)EditorGUILayout.ObjectField("Cell", cell, typeof(Cell), false, _gameObjectOptions);
            equip.SetCell(x, y, tmpCell);
            Sprite sprite    = equip.GetSprite(x, y);
            Sprite tmpSprite = (Sprite)EditorGUILayout.ObjectField("Sprite", sprite, typeof(Sprite), false, _gameObjectOptions);
            equip.SetSprite(x, y, tmpSprite);

            EditorGUI.indentLevel--;
        }
    }