- Home /
Editor.OnSceneGUI never called.
I'm trying to understand why OnEditorGUI is never called on my custom Editor subclass.
the code is as follow:
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Bezier))]
public class BezierEditor : Editor
{
public override void OnInspectorGUI ()
{
base.OnInspectorGUI ();
Debug.Log("on inspector gui");
}
public void OnSceneGUI()
{
Debug.Log("on scene gui");
}
}
OnInspectorGUI is properly called and the debug show for it, but not for OnSceneGUI. I'm using the latest unity version (3.4.1f5)
Are you sure? OnSceneGUI is only called when the sceneview is repainted...
This seems to be a bug with the editor, on mac. For example the OnInspectorGUI function is not called for iTween Path Editor either (http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/). Is there a place to report bugs with unity?
Answer by huulong · Jan 06, 2017 at 11:28 AM
Not a definitive fix, but if it happens again you can reset the editor Layout with the top-right button (for instance to Default).
I had the same issue with my custom editor and a tilemap plugin that stopped displaying its the tiling tools. Closing and restarting the editor didn't solve it. Resetting the layout solved it.
Still working in 2017.3, you saved me a lot of trouble Sir !
This worked for me, and then it happened again a short time later! I found that resetting the layout automatically turns Gizmos visibility back on, as per @$$anonymous$$usapKahraman comment. Resetting the whole Editor Layout isn't necessary.
TL;DR Editor.OnSceneGUI only runs when scene view Gizmos is toggled on.
Had the same bug, but this workaround still did the trick for me in Unity 2019.3.15.
Wow, I had the same issue with Unity 2021 this week and I've just found my own answer that I had totally forgotten about! And it still works!
In the meantime I sent a bug report to Unity, so now they have a sample project with a failing layout to work on. Hopefully they can fix the root of the issue even without details of how I broke the layout.
@xtyler if it happens to you regularly, try to spot the kind of GUI warnings that appear in the editor, I may add them to my bug report as extra info. Otherwise yes, you should only reset the layout if the Gizmo toggle doesn't work (in my case toggling it off and on again didn't fix the issue)
Answer by MusapKahraman · Oct 29, 2019 at 05:17 PM
Turning the visibility of Gizmos on in the scene view worked for me. I had turned them off for some reason and OnSceneGUI stopped being called.
Yes. Problem is with Gizmos being turned off. Reopening scene window or resetting the editor Layout also reset Gizmos settings in scene window to default on.
Answer by Sarseth · Jan 12, 2016 at 09:33 PM
Old question. But maybe someone find same issue. When I have "DEBUG" enabled on inspector, onGUI does not work for me either. I must disable it. I'm guessing it's a bug, cause why it would stop working?
I found It continue working when I move my mouse on the scene window. BTW,it still won't work when I just put the mouse on the scene window but not move it. I don't know how to solve it. It has been FIVE year,I can't believe it is a bug. $$anonymous$$aybe there is something wrong with our codes,but we don't know.
The editor is completely event driven. OnSceneGUI is only called when it should process an event. You can call SceneView.RepaintAll();
to force a repaint of all open sceneviews. Please stop posting comments on this question since you've asked your own
That's not a bug. when you switch the inspector into debug mode, no custom editor will be drawn. Not even the built-in custom editors. The debug mode is just for debugging.