Hi, Is there any way to access the Editor camera's position and rotation. What I mean is the camera view from the Editor not the main camera object that you created in the scene.
Hi,
There is for this a very simple tool to align the camera to the scene view.
1: select the camera you want to align 2: in the Unity menu, select gameObject -> aLignWithView
Done. Not only you have aligned the camera to the scene view so that the game will have the same point of view but you can also know the transform of the scene as a direct side effect ( but I guess aligning the camera was what you wanted to achieve anyway)
Hope it helps,
Bye,
Jean
For what I need it was actually pretty simple.
SceneView.currentDrawingSceneView.camera
getting that let me save the position of the editor camera with a button in the inspector.
Short Answer:
SceneView.lastActiveSceneView.rotationLong Answer (with example):
The following will create a menu option in the “Window” menu called “SceneViewCameraTest”.
Every time you call (or click on) this window, it will show you the Scene View's camera rotation. (converting these to angles is well-documented, so I've not bothered with that in this example.)
Create a c# script called "SceneViewCameraTest.cs" using the following code:
using UnityEngine;
using UnityEditor;
public class SceneViewCameraTest : EditorWindow {
[MenuItem ("Window/SceneViewCameraTest")]
static void Init () {
// Get existing open window or if none, make a new one:
SceneViewCameraTest window = (SceneViewCameraTest)EditorWindow.GetWindow (typeof (SceneViewCameraTest));
}
void OnGUI () {
EditorGUILayout.TextField ("SceneViewCameraAngle", ""+SceneView.lastActiveSceneView.rotation);
}
}
Here you can take a look at an asset that saves the editor camera angles and you can go back and forward the states you saved: