Simple toggle camera button

ok, so I have three cameras in my scene. My problem is I can’t have one button for each - it’s just not nice. So how do I go around and actually use one button to toggle (clockwise, endlessly) between my cameras? Currently I use this rough approach:

if (Cam1) {
		Cam1.enabled = true;
		Cam2.enabled = false;
		Cam3.enabled = false;

and on GUI function, the button :

 if (GUI.RepeatButton(Rect(200,10,50,50),"Cam1"))

and so on, for each camera. Where should I look? The toggle button from docs doesn’t inspire help me much, I get all sorts of fancy results when I try to build upon that :slight_smile:

Use a index to keep track of the current camera. Something like this:

var cameras : Camera[];
var selectedCamera : int = 0;

function Awake(){

function OnGUI () {
	var cameraString = "Camera "+(selectedCamera+1); // show "Camera X", where X is 1-indexed
	if (GUI.Button(new Rect(0,0,100,50),cameraString)){
		if (selectedCamera==cameras.Length){

function UpdateSelectedCamera(){
	for (var i=0;i<cameras.Length;i++){
		cameras*.enabled = i==selectedCamera;*
  • }*