Unity3D相机切换2

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;
        }
}


猜你喜欢

转载自bvu.iteye.com/blog/1745531