Unity-カメラの切り替え

ボタンを2つ用意してカメラを切り替えます

スクリプトを適用した後,カメラをアサインしてください.

var cameraA : GameObject;
var cameraB : GameObject;
cameraA.camera.enabled = true;
cameraB.camera.enabled = false;
 function OnGUI () {
// background box
GUI.Box (Rect (Screen.width -110,10,100,90), "Cam Type");
// first button
if (GUI.Button (Rect (Screen.width -100,40,80,20), "RGB CAM")) {
cameraA.camera.enabled = true;
cameraB.camera.enabled = false;
  }

// second button.
if (GUI.Button (Rect (Screen.width -100,70,80,20), "Move CAM")) {
cameraA.camera.enabled = false;
cameraB.camera.enabled = true;
  }
}