Unity3D相机切换
var camera0 : Camera;
var camera1 : Camera;
function Update () {
if (Input.GetKey ("1"))
{
camera1.enabled = true;
camera0.enabled = false;
}
if (Input.GetKey ("2"))
{
camera1.enabled = false;
camera0.enabled = true;
}
}
function OnGUI () {
GUI.Box (Rect (10,10,100,90), "Camera Switch");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (20,40,80,20), "Camera 1")) {
camera1.enabled = true;
camera0.enabled = false;
}
// Make the second button.
if (GUI.Button (Rect (20,70,80,20), "Camera 2")) {
camera1.enabled = false;
camera0.enabled = true;
}
}
[img]http://dl.iteye.com/upload/attachment/0078/6304/a24f4d39-1526-37db-8200-98c73340e1ef.jpg[/img]
var camera0 : Camera;
var camera1 : Camera;
function Update () {
if (Input.GetKey ("1"))
{
camera1.enabled = true;
camera0.enabled = false;
}
if (Input.GetKey ("2"))
{
camera1.enabled = false;
camera0.enabled = true;
}
}
function OnGUI () {
GUI.Box (Rect (10,10,100,90), "Camera Switch");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (20,40,80,20), "Camera 1")) {
camera1.enabled = true;
camera0.enabled = false;
}
// Make the second button.
if (GUI.Button (Rect (20,70,80,20), "Camera 2")) {
camera1.enabled = false;
camera0.enabled = true;
}
}
[img]http://dl.iteye.com/upload/attachment/0078/6304/a24f4d39-1526-37db-8200-98c73340e1ef.jpg[/img]