Iterating a random list cameras

I have a class where I need to run through a list containing 3 cameras (or view ports) for student project I’m making.

I created three camera variables and initialized them with the three cameras I set up in the game world. In addition I made a camera list and added each of the camera variables within the list.

Now, I am working with only one scene (called “MyScene”) and every time the user presses the “Next Button” it loads “MyScene” but it starts with a camera that is stored in my camera list.

My question is how do I make it to whenever I load a specific scene I get a different view port each time?

I made a diagram depicting the task at hand:

I didn’t understand what you are trying to do exactly, but the way i see it, i think that you need to keep tracking of “last used camera” before clicking “next” and in the new scene you use another camera different from the previous one, for that you need to use a script that contain DontDestroyOnLoad which you store in it your last used camera and based on that you pick a different camera (you probably going to face duplication problem, just search for it here and you’ll find more than one answer)

In the script that contains your Camera List I would add a Start() function that calls the following:


Where myCameraList is your list of cameras.

Of course this is a random selection so it is possable that you will get the same camera twice.