Hi, I want to set the transform of the main camera using the transformation that it’s currently used in the scene window.
I am trying to find how to access that information from an editor script but I cannot find the class/method that I should use.
Thanks in advance.
Maybe this is what you seek?
public Camera c;
private Transform tf;
tf = (Transform) c.GetComponent("Transform");
You can get every component in the inspector with the GetComponent method :)[/code]
The problem is that I want to “read” the transformation that it is currently used in the scene window. It is not a camera listed in the hierarchy panel, I don’t event know if there exist a Camera object related to that view or it is simply a transformation stored elsewhere.
Then, with that transformation, I want to set it to a real camera of the game (I know how to do that, the problem is in the first part).
Thanks for your reply.
I think you’re looking for something like this?
@MenuItem("Tools/Match Scene Camera")
static function MatchSceneCameraMenu(command : MenuCommand)
{
Camera.main.transform.position = Camera.current.transform.position;
Camera.main.transform.rotation = Camera.current.transform.rotation;
}