public static void EditTile(TiledTileset tileset, int lid)
        {
            TiledTileWindow window = CreateInstance <TiledTileWindow>();

            window.tileset = tileset;
            window.lid     = lid;
            window.ShowUtility();
        }
Пример #2
0
        void DrawTilesetEditing()
        {
            if (target.tilesets == null || target.tilesets.Length != data.tilesets.Length)
            {
                target.tilesets = new TiledTileset[data.tilesets.Length];
            }
            if (showTilesets == null || showTilesets.Length != target.tilesets.Length)
            {
                showTilesets = new bool[target.tilesets.Length];
            }
            for (int i = 0; i < target.tilesets.Length; i++)
            {
                TiledTilesetData tilesetData = data.tilesets[i];

                if (target.tilesets[i] == null)
                {
                    target.tilesets[i] = CreateInstance <TiledTileset>();
                }
                target.tilesets[i].Init(tilesetData, fullPath);

                if (!(showTilesets[i] = EditorGUILayout.Foldout(showTilesets[i], tilesetData.name)))
                {
                    continue;
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginVertical();
                EditorGUI.indentLevel--;

                target.tilesets[i] = EditorGUILayout.ObjectField("Tileset Asset", target.tilesets[i], typeof(TiledTileset), true) as TiledTileset;

                for (int col = 0; col < tilesetData.columns; col++)
                {
                    EditorGUILayout.BeginHorizontal();
                    for (int row = 0; row < tilesetData.tilecount / tilesetData.columns; row++)
                    {
                        int lid = row + col * tilesetData.columns;
                        EditorGUILayout.BeginVertical();

                        if (GUILayout.Button(target.tilesets[i].tiles[lid].texture, GUILayout.ExpandWidth(true)))
                        {
                            TiledTileWindow.EditTile(target.tilesets[i], lid);
                        }

                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Save Tileset"))
                {
                    string path = EditorUtility.SaveFilePanelInProject("Save Tileset", tilesetData.name, "asset", "Message");
                    if (path.Length > 0)
                    {
                        AssetDatabase.CreateAsset(target.tilesets[i], path);
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }