- Home /
Question by
OliverAnthony · Jun 22, 2015 at 09:02 PM ·
guieditorguilayoutonscenegui
GUI & GUILayout methods no longer work in OnSceneGUI()
For example, the following code.
[CustomEditor(typeof(LayoutObject))]
public class LayoutAssistant : Editor {
void OnSceneGUI () {
if (GUILayout.Button ( "Test" ) ) {
//whatever
}
}
}
This results in an extremely wide (much wider than it needs to be to fit the string passed to the method) button being drawn seemingly in the Canvas space (???) of the SceneView (when I zoom out, the button scales, when I pan, the button moves around with the rest of scene). All this, except only in the upper right quadrant of the SceneView. If I pan far enough that the button moves into any of the other quadrants, it simply gets cut off, eventually disappearing entirely.
Any ideas? Did I miss an important PSA on changes to using GUI calls in the SceneView?
Comment
Answer by mitaywalle · Oct 22, 2015 at 08:13 AM
Hello, @HexGuy . I've run to this issue too.
All you need is to write
Handles.BeginGUI();
...
Handles.EndGUI();