I want to know if I am doing this right. I am working on this scene where I have three different cameras. One if them is the main camera which is set to start at default. Then it changes to the next camera when the user is done and presses a button.
Right now I have three camera variables called: viewport1, viewport2, viewport3
In my start function I have all three viewports initialized as
Viewport1 = GameObject.Find(“MainCamera”).camera;
Viewport2 = GameObject.Find(“IsometricCamera”).camera;
ViewPort3 = GameObject.Find("TopView).camera;
Then I started enabling them right afterwards in the same start function:
Viewport1.enabled = true;
ViewPort2.enabled = false;
ViewPort3. Enabled = false;
In an Update I set them up in a switch statement where I enable / disable them as the user progresses. But the thing is that I am facing a certain problem:
For starters I get a null reference exception. That points to the first viewport. But if I comment out the line it points to the next viewport and so on. In addition the main camera is no longer the first camera to be set up, it is actually the third viewport camera that is the default camera now.
I also have this class attached to the main camera object.
How do I get rid of this null reference exeption and how do I get the main camera to be the first camera to be loaded?