- Home /
How do I create a Camera and make it mainCamera with csharp script ?
How do I create a Camera object in csharp script. I also want to assign it as MainCamera with tags. Currently I am getting this error :
You probably need to assign the levelCamera variable of the StartUp script in the inspector. These are the two lines of code which concern the camera :UnassignedReferenceException: The variable levelCamera of 'StartUp' has not been assigned.
public Camera levelCamera; ...and levelCamera.enabled = true;
Comment
Answer by DaveA · Oct 28, 2011 at 05:13 PM
You have not assigned a Camera. You normally would drag one in via the Inspector, but to anwser your question, you would do something like (untested):
var cam = AddComponent(Camera);
cam.tag = "mainCamera";
Your answer
Follow this Question
Related Questions
Adding lights and cameras to scenes with cSharp script 2 Answers
Generate DLL for aprilTag detection with VISP_unity package 0 Answers
Turret With Raycast Camera 1 Answer
Headbobber script in C#? 3 Answers
How to make a FLASH 4 Answers