Question by
artanist · Aug 05, 2016 at 06:59 PM ·
editorwindowgizmo
How do I create a scene view in an editor window WITH the gizmo activated ?
Hello, I am trying to create an editor window with a scene view in it. The problem I got, is that it render it in game mode and I want it to show it like in the scene view with the gizmo. I tried the following code, but it only renders in game mode.
using UnityEngine;
using UnityEditor;
public class TestWindow : EditorWindow
{
public Camera m_Cam = Camera.main;
private Rect sceneRect;
[MenuItem("Test/TestWindow")]
static void Init()
{
TestWindow window = (TestWindow)EditorWindow.GetWindow(typeof(TestWindow));
window.autoRepaintOnSceneChange = true;
window.Show();
}
void OnGUI()
{
// important: only render during the repaint event
if (Event.current.type == EventType.Repaint)
{
sceneRect = new Rect(new Vector2(10f,0f), new Vector2(100f,100f));
m_Cam.pixelRect = sceneRect;
m_Cam.cameraType = CameraType.SceneView;
m_Cam.Render(); // render the camera into the window
}
}
}
To be specific, I want to be able to see the colliders bound around an object that I would show in that editor window.
Comment