添加脚本位置
First Person Controller: 添加CameraSwitch脚本
下层物体 graphic
MainCamera
AnimationCamera:从3dmax中导入,添加CameraSwitch脚本
下层物体 camera 新建并作为子物体
cameraswitch代码:
var camera1 : Camera;
var camera2 : Camera;
//var customskin : GUISkin;
private var programeGoon : boolean = true;
/*function Start(){
programeGoon = true;
//mouselook1 = GetComponent("mouseCameraCsharp");
}*/
function Update () {
if(programeGoon)
{
camera1.enabled = true;
camera2.enabled = false;
programeGoon = false;
}
var fpswalker : FPSWalker = GetComponent(FPSWalker);
var mouseControl = GetComponent("RightMouseControl");
if(camera1.enabled)
{
mouseControl.enabled = true;
fpswalker.enabled = true;
}
if(!camera1.enabled)
{
mouseControl.enabled = false;
fpswalker.enabled = false;
}
}
function OnGUI () {
//GUI.skin = customskin;
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;
camera2.enabled = false;
}
// Make the second button.
if (GUI.Button (Rect (20,70,80,20), "Camera 2")) {
camera1.enabled = false;
camera2.enabled = true;
}
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ouczoe/archive/2010/01/11/5174240.aspx