Question by 
               Cerebralbore101 · Apr 23, 2016 at 12:59 AM · 
                printing  
              
 
              How do I find and print the current camera I am using?
I am using the book "Unity for Absolute Beginners".
It seems like there have been changes to unity where, camera is no longer a gameObject, but a class. Because of this the following code returns a null object reference error. How would I change the code so that the game finds the main camera in the scene and then prints it properly?
             favoriteFood = GameObject.Find("Carrots");
     print ("The" + gameObject.name + "'s favorite food is " + favoriteFood + ".");
     theView = GameObject.Find("Main Camera").GetComponent<Camera>();
     myCustomScript = GameObject.Find("Walkway").GetComponent<VariablesTest>();
     print("The view uses " + theView.gameObject.name);
     print ("The script is from the " + myCustomScript.gameObject.name + " object");
 
              
               Comment
              
 
               
              Your answer