- Home /
The question is answered, right answer was accepted
How to get Editor Window to update immediately in Editor Mode/Play Mode
Trying to make an editor window that will show the distance between two selected gameobjects. I used`OnDrawGizmosSelected()` which calls some stuff and successfully calculates the distance. The distance is correct when I log it (OnDrawGizmosSelected called a few times per second when object is selected)
private void OnDrawGizmosSelected()
{
Distance.CheckSelect();
}
This updates some static variable in my Distance class.
My editor window reads this static variable in OnGUI, but OnGUI is only called sometimes, whereas I want the Distance to be reflected immediately on the window as a read only variable.
private void OnGUI()
{
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.FloatField("Distance: ", Distance.distance);
EditorGUI.EndDisabledGroup();
}
How do I get my EditorWindow to update instantly in both edit and play mode?
Answer by jmanchuck · Oct 21, 2020 at 04:02 PM
The answer was EditorWindow.Update() ... kept searching for things apart from the EditorWindow docs itself
Follow this Question
Related Questions
SearchableEditorWindow 2 Answers
Any way to attach a bit of code to individual UI Windows [Editor] 1 Answer
Color Palette Editor Window 1 Answer