纳金网
标题:
[技术问答]unity如何用按钮切换相机内容
[打印本页]
作者:
驰骋的风
时间:
2013-3-16 00:23
标题:
[技术问答]unity如何用按钮切换相机内容
原问题:今天想问大家一个如何用按钮切换相机内容,因为不懂脚本,希望哪位朋友能帮忙写一个
我发一下示意图片吧,方便理解
现在我假设场景里有3个相机,我希望能用按钮切换到对应的相机场景中
答案:、var camera0 : Camera;
var camera1 : Camera;
var camera2 : Camera;
var icon01:Texture;
function OnGUI () {
if(GUI.Button (Rect (Screen.width/2-60,Screen.height-60,50,50), GUIContent (icon01, "Sence01")))
{
camera0.enabled = ***e;
camera1.enabled = false;
camera2.enabled = false;
}
if(GUI.Button (Rect (Screen.width/2,Screen.height-60,50,50), GUIContent (icon01, "Sence02")))
{
camera1.enabled = ***e;
camera0.enabled = false;
camera2.enabled = false;
}
if(GUI.Button (Rect (Screen.width/2+60,Screen.height-60,50,50), GUIContent (icon01, "Sence03")))
{
camera2.enabled = ***e;
camera0.enabled = false;
camera1.enabled = false;
}
}
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5