static void ShowWindow() { SpriteSheetEditor window = EditorWindow.GetWindow <SpriteSheetEditor>(EditorPrefs.GetBool(typeof(SpriteSheetEditor).Name + "Detachable", false), "Create Sprite Sheet", true); window.minSize = new Vector2(windowWidth, 50); window.maxSize = new Vector2(windowWidth, 400); window.Repaint(); }
void OnGUI() { //Header GUILayout.BeginArea(new Rect(7, 0, this.position.width - 14, this.position.height)); GUILayout.Space(5); GUILayout.Label("Create Sprite Sheet from Sequence", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); detachable = EditorGUILayout.Toggle("Detachable", detachable, GUILayout.Height(20)); if (GUI.changed) { EditorPrefs.SetBool("detachable", detachable); this.Close(); SpriteSheetEditor.ShowWindow(); } if (GUILayout.Button("Choose Folder with Sequence", GUILayout.Height(25))) { folderpath = EditorUtility.OpenFolderPanel("Folder where PNG Sequence is located", getSelectedPath(), ""); } GUILayout.Space(5); if (string.IsNullOrEmpty(folderpath)) { EditorGUILayout.HelpBox("No folderpath given!", MessageType.Warning); } else { // just a little reminder that textures have to be advanced to be read (The Unity Exception thrown says pretty much the same thing but still) EditorGUILayout.HelpBox("Textures have to be Advanced & Read/Write has to be enabled! Texture Files have to be in PNG format.", MessageType.Info); xAxis = EditorGUILayout.IntField("#Sprites on X-Axis:", xAxis, GUILayout.Height(20)); if (GUILayout.Button("Create Spritesheet", GUILayout.Height(25))) { createSpriteSheetFromPNGSequence(folderpath); } } GUILayout.Space(5); //Resize window if (Event.current.type == EventType.Repaint) { Rect rect = GUILayoutUtility.GetLastRect(); this.minSize = new Vector2(windowWidth, rect.y + 4); this.maxSize = new Vector2(windowWidth, rect.y + 4); } EditorGUI.EndChangeCheck(); GUILayout.EndArea(); }