Mateusz
Mateusz

Forcing Unity inspectors to redraw every frame

Unity inspectors aren’t repainted every frame by default. It is an optimization that Unity uses to make the editor slightly more responsive. You might notice inspectors don’t update until you move your mouse over them - this is why.

Forcing inspectors to redraw every frame

If you have a custom editor for your type, simply override:

Editor.RequiresConstantRepaint
Checks if this editor requires constant repaints in its current state.

Here’s a snippet of how to do this for any component:

0
1
2
3
4
5
6
7
8
9
public sealed class MyComponent : UnityEngine.MonoBehaviour
{
#if UNITY_EDITOR
    [UnityEditor.CustomEditor(typeof(MyComponent))]
    sealed class Editor : UnityEditor.Editor
    {
        public override bool RequiresConstantRepaint() => true;
    }
#endif
}

(And by the way, yes, I like putting my editors inline like this when they’re short)