Problem accessing the scene camera

Hello, I’m trying to access the editor’s camera (also known as Scene Camera) through this simple code in an AWAKE() function:

Debug.Log("Camera.current = " + Camera.current);

… But it always returns “null”, even though the scene camera panel is selected when I start the game through CTRL+P. Is that a known Unity bug or am doing something wrong?

  1. Your scene camera can be your game camera and you can mark it as the main camera by changing the ‘tag’ to ‘MainCamera’.
  2. Or a script attached to your player camera can have a public variable of type ‘Camera’ to which you drag the scene camera and from which you access it:


var mainCam : Camera; // Drag the scene camera to this exposed variable once you attach this sctipt to the player camera

void Start()
  transform.position = mainCam.position;
  transform.rotation = mainCam.rotation;