Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small Unity 3D Editor Extension that shows current editor state (Editing/Compiling/Paused/Updating). In order to use this script, just put it in Editor folder. Screenshot: http://goo.gl/VJukpV
using System;
using UnityEditor;
using UnityEngine;
namespace Nravo.Editors.Utils {
public class EditorStateWindow : EditorWindow {
static string _currentState = "";
static GUIStyle _lableStyle = new GUIStyle();
[MenuItem("Window/Editor State")]
public static void ShowWindow() {
EditorWindow.GetWindow<EditorStateWindow>(false, "----", true);
}
void OnEnable() {
_lableStyle.fontSize = 24;
_lableStyle.alignment = TextAnchor.MiddleCenter;
_lableStyle.padding = new RectOffset(10, 10, 10, 10);
_lableStyle.normal.textColor = Color.gray;
}
void OnGUI() {
GUILayout.Space(36f);
EditorGUILayout.LabelField(_currentState, _lableStyle);
}
void Update() {
_currentState = GetCurrentState();
this.title = _currentState;
Repaint();
}
string GetCurrentState() {
var state = "Editing";
_lableStyle.normal.textColor = Color.gray;
if(EditorApplication.isCompiling) {
state = "Compiling";
_lableStyle.normal.textColor = Color.red;
} else if(EditorApplication.isPaused) {
state = "Paused";
_lableStyle.normal.textColor = Color.yellow;
} else if(EditorApplication.isPlaying) {
state = "Playing";
_lableStyle.normal.textColor = Color.green;
} else if(EditorApplication.isUpdating) {
state = "Updating";
_lableStyle.normal.textColor = Color.gray;
}
return state;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.