ITeye博客

Unity3D相机切换2

chinaloft · 2012-12-10 23:39 · Unity3d手机游戏开发 · 移动开发 · Markdown

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

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。