Hi Everyone,
I’m currently taking my first look into “extending the editor”.
What I am trying to do as a test for myself to learn it is
creating a window that has it’s own camera an can render
the Scene object.
Here is my current code:
using UnityEngine;
using UnityEditor;
using System.Collections;
public class MyWindow: EditorWindow
{
[MenuItem ("Window/MyWindow")]
static void Init ()
{
MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow));
Handles.DrawCamera(window.position, Camera.current);
}
void OnGUI ()
{
GUILayout.Label ("My window test", EditorStyles.boldLabel);
}
}
I have just no idea on how to create the camera itself, because I think
that I have to use Handles.DrawCamera, but I don’t know how to
‘create’ the custom camera.
Right now as you can see I use Camera.current, which does nothing at all.
So in short:
How do I create a camera in a custom window that renders gameobjects, like the scene view.
Thanks in advance 
Create one like normal, then destroy it in OnDestroy.
–Eric
Thanks for responding so quick Eric. Could you maybe give a small code sample of how to do such a thing “like normal”. I would like it so it doesn’t show up in the inspector. Like the scene view camera.
Anyone knows how to do this?
like normal means: create game object, add component camera
Ok, will this mean it is visible in the hierarchy? Because the camera you look through in scene view isn’t visible in the hierarchy…
Yes it will be visible in the hierarchy (theoretically. practically GameObject has a hide flag that you can use to not show game objects in the hierarchy :))
There is no way for you to use the scene camera, its only available to the scene view.
The only thing you could make use of is the preview functionality but I doubt thats what you were looking for
Thanks dreamora, that worked. I was wondering about the movement of the camera I created. If I multiply the speed by deltaTime the camera moves really slow and I need to use a float like 100000000 to make it move ok. If I don’t use delta time, it moves insanely fast.
The code works very well in game.
What should I use to move the camera correct in my editor window?