private void OnGUI() { if (thisWindow == null) { GetCurrentWindow(); return; } //Get current event Event e = ProcessEvents(); if (isLoaded) { GUILayout.BeginArea(new Rect(MA_TextureAtlasserProUtils.VIEW_OFFSET, MA_TextureAtlasserProUtils.VIEW_OFFSET, position.width - (MA_TextureAtlasserProUtils.VIEW_OFFSET * 2), position.height - (MA_TextureAtlasserProUtils.VIEW_OFFSET * 2))); GUILayout.BeginVertical(); //Input options textureAtlasName = EditorGUILayout.TextField("Atlas name", textureAtlasName, GUILayout.ExpandWidth(true)); if (textureAtlasName == "Atlas name" || string.IsNullOrEmpty(textureAtlasName)) { nameError = true; GUI.backgroundColor = Color.red; GUILayout.Box("Error: Enter a valid atlas name!", EditorStyles.helpBox); GUI.backgroundColor = Color.white; } else { nameError = false; } textureAtlasSize.x = EditorGUILayout.IntField("Atlas width", (int)textureAtlasSize.x, GUILayout.ExpandWidth(true)); if (linkedAtlasSize) { linkedAtlasSize = EditorGUILayout.Toggle("link height", linkedAtlasSize, GUILayout.ExpandWidth(true)); textureAtlasSize.y = textureAtlasSize.x; } else { textureAtlasSize.y = EditorGUILayout.IntField("Atlas height", (int)textureAtlasSize.y, GUILayout.ExpandWidth(true)); } if (!Mathf.IsPowerOfTwo((int)textureAtlasSize.x) || !Mathf.IsPowerOfTwo((int)textureAtlasSize.y)) { GUI.backgroundColor = Color.yellow; GUILayout.Box("Warning: Atlas size value isn't a power of two!", EditorStyles.helpBox); GUI.backgroundColor = Color.white; } if (textureAtlasSize.x < 64 || textureAtlasSize.y < 64) { sizeError = true; GUI.backgroundColor = Color.red; GUILayout.Box("Error: The minimum atlas size is 64!", EditorStyles.helpBox); GUI.backgroundColor = Color.white; } else { sizeError = false; } //Create if (!nameError && !sizeError) { if (GUILayout.Button("Create Atlas", GUILayout.ExpandWidth(true), GUILayout.Height(37))) { textureAtlas = MA_TextureAtlasserProUtils.CreateTextureAtlas(textureAtlasName, textureAtlasSize); if (curWindow != null) { curWindow.textureAtlas = textureAtlas; } else { Debug.Log("No editor window found"); } CloseWindow(); } } GUILayout.EndVertical(); GUILayout.EndArea(); } if (e.type == EventType.Repaint) { isLoaded = true; } }