I am working on a game that spawns different objects at runtime, each with their own camera. For this game, I need to be able to cycle through each camera. Since I won’t have a predefined list of cameras, how can I go about getting access to these cameras as they get generated, so that I can switch between them if I desire? Is this possible through a script?
Nevermind, I was able to accomplish this by making a new camera list:
public List<Camera> camList = new List<Camera>();
And then for each Rigidbody (a cube in this case), I would append the camera (which was a child of the cube) to the camera list.
Result = Instantiate(Cube, new Vector3(Random.Range(-10.0f, 10.0f), Random.Range(1.0f, 10.0f), 0), Quaternion.identity) as Rigidbody;
camList.Add(Result.GetComponentInChildren<Camera>());