Esempio n. 1
0
        public static ReorderableList CreateBrushReorderableList(Tileset tileset)
        {
            ReorderableList brushRList = new ReorderableList(tileset.Brushes, typeof(Tileset.BrushContainer), true, true, true, true);

            brushRList.displayAdd         = brushRList.displayRemove = false;
            brushRList.drawHeaderCallback = (Rect rect) =>
            {
                EditorGUI.LabelField(rect, "Brushes", EditorStyles.boldLabel);
            };
            brushRList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                Tileset.BrushContainer brushContainer = tileset.Brushes[index];
                if (brushContainer.BrushAsset)
                {
                    Rect rToggle = new Rect(rect.x, rect.y, 16f, EditorGUIUtility.singleLineHeight);
                    Rect rTile   = new Rect(rect.x + 16f, rect.y, tileset.VisualTileSize.x, tileset.VisualTileSize.y);
                    Rect rTileId = rTile;
                    rTileId.x     += rTile.width + 20; rTileId.width = rect.width - rTileId.x;
                    rTileId.height = rect.height / 2;

                    Rect tileUV = brushContainer.BrushAsset.GetAnimUV();
                    if (tileUV != default(Rect))
                    {
                        GUI.Box(new Rect(rTile.position - Vector2.one, rTile.size + 2 * Vector2.one), "");
                        GUI.DrawTextureWithTexCoords(rTile, tileset.AtlasTexture, tileUV, true);
                    }

                    brushContainer.BrushAsset.ShowInPalette = EditorGUI.Toggle(rToggle, GUIContent.none, brushContainer.BrushAsset.ShowInPalette, STEditorStyles.Instance.visibleToggleStyle);
                    GUI.Label(rTileId, "Id(" + brushContainer.Id + ") " + brushContainer.BrushAsset.name);
                }
                else
                {
                    tileset.RemoveInvalidBrushes();
                }
            };

            return(brushRList);
        }