- Home /
Change Camera With a Script
Hello,
I know this question is asked a few times but it doesn't seen to work for me. I tried this code to change the cameras in my IOS project with a button:
var Cam1 : Camera; var Cam2 : Camera; function Start() { Cam1.enabled = true; Cam2.enabled = false; } function Clicked() { if (Cam1.enabled == true) { Cam1.enabled = false; Cam2.enabled = true; } else if (Cam2.enabled == true) { Cam1.enabled = true; Cam2.enabled = false; } }
But when I test it, it says: 'No cameras rendering' while I have them both enabled in the inspector... Sorry if this question sounds a bit nooby, I'm probably missing something very obvious. (I'm new to Unity)
Answer by Samuel014 · Jan 15, 2019 at 11:25 AM
Okay, I fixed it with deleting the seconds camera, and just creating an other one.
Your answer
![](https://koobas.hobune.stream/wayback/20220612185804im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with gravity in a Third Person Controller 0 Answers
How to select Object's voids through Inspector tab? 2 Answers
Why is my Unity script overwriting other game objects on which it is attached to? 1 Answer
How to make a smooth camera transition 1 Answer
FPS increase when selecting an Camera due to VSync 0 Answers