Hello! I have a level editor that runs inside the Unity editor. I would love to give the level designers the ability to press a button and play what they are looking at.
Basically, I want to know the initial center of the scene view when the game is running. We use an orthographic camera. I plan on using Camera.ViewportToWorldPoint().
Option A: Apparently I can get the scene camera in editor scripts through Camera.current, but I don’t know how to start the game from editor scripts.
Option B: I can start the game then get the scene camera to find out what should load first, but I don’t know how to get the scene camera once the game is playing.
So anyone know how I can start game with editor scripts or get the scene camera while playing?
I didn’t know EditorApplication.isPlaying has a setter, I just assumed it was read-only so thanks for that!
As for void OnSceneGUI(SceneView), my console gets spammed with errors when I try to do that. I’m going to try using Camera.current next and see if that gives me the scene camera or not.
Camera.current works for the scene view camera in OnSceneGUI() but not in OnInspectorGUI(). Which makes sense. I’m able to get a position for the center of the scene view and run the game now. Thanks @hpjohn for your help!
Ah yeah I had that, still getting those errors. They aren’t compiler errors. They don’t appear until I saved my editor script then looked at the console. The error seems to indicate 1 parameter is the wrong number of parameter’s it’s looking for. I’m wondering maybe it’s a Unity version specific? I couldn’t find any documentation on the SceneView class either. I’m on 4.5.4 right now.