示例#1
0
        private void ShowShapeSettings(Shape shape, int index)
        {
            var isShow = EditorGUILayout.Foldout(index == _selectedShapeIndex, shape.ShapeName);

            if ((index == _selectedShapeIndex) != isShow)
            {
                _selectedShapeIndex = index == _selectedShapeIndex ? -1 : index;
            }

            if (!isShow)
            {
                return;
            }

            shape.ShapeName = EditorGUILayout.TextField("Shape Name", shape.ShapeName);

            shape.ShapeColor = EditorGUILayout.ColorField("Shape Color", shape.ShapeColor);

            for (var i = 0; i < shape.Height; i++)
            {
                EditorGUILayout.BeginHorizontal();
                for (var j = 0; j < shape.Width; j++)
                {
                    var style = _uncheckShapeStyle;
                    if (shape.At(i, j))
                    {
                        style = _checkShapeStyle;
                    }

                    if (GUILayout.Button("", style))
                    {
                        shape.SetAt(i, j, !shape.At(i, j));
                    }
                }

                EditorGUILayout.EndHorizontal();
            }
            Separator();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Row"))
            {
                shape.AddRow();
            }
            if (GUILayout.Button("Add Colum"))
            {
                shape.AddColum();
            }
            EditorGUILayout.EndHorizontal();
            Separator();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Optimize Shape"))
            {
                shape.OptimizeShape();
            }
            if (GUILayout.Button("Delete Shape"))
            {
                _serializedObject.Shapes.RemoveAt(_selectedShapeIndex);
                _selectedShapeIndex = -1;
            }
            EditorGUILayout.EndHorizontal();

            Separator();
        }