我想要实现用按钮切换4个相机,运行没问题,可以出现按钮,但是按钮不管用。
运行时出现这个错误the variable camera0 of ieheaQ2 has not been assigned 。 you probably need to assgin the camera4 varible of the iehuanQ2 script inthe inspector
然后代码错误指向camera4.active=false;这一行
还有个按钮风格也不能用,所以我先隐藏了
代码实在看不出问题了,求助大神
下面是代码
var camera1:GameObject;
var camera2:GameObject;
var camera3:GameObject;
var camera4:GameObject;
function OnGUI ()
//GUI.skin=uiskin;
{
if(GUI.Button(Rect(Screen.width/2+150,Screen.height/2+100,70,30),"camera1"));
{
print("you click camera2 button");
onActiveFalse();
camera1.active=true;
}
// GUI.skin=null;
if(GUI.Button(Rect(Screen.width/2+240,Screen.height/2+195,200,70),"camera2"));
{
onActiveFalse();
camera2.active=true;
} if(GUI.Button(Rect(200,200,73,33),"文字按钮"));
{
onActiveFalse();
camera3.active=true;
} if(GUI.Button(Rect(200,200,74,34),"文字按钮"));
{
onActiveFalse();
camera4.active=true;
}
}
function onActiveFalse()
{
camera1.active=false;
camera2.active=false;
camera3.active=false;
camera4.active=false;
拜谢大神
运行时出现这个错误the variable camera0 of ieheaQ2 has not been assigned 。 you probably need to assgin the camera4 varible of the iehuanQ2 script inthe inspector
然后代码错误指向camera4.active=false;这一行
还有个按钮风格也不能用,所以我先隐藏了
代码实在看不出问题了,求助大神
下面是代码
var camera1:GameObject;
var camera2:GameObject;
var camera3:GameObject;
var camera4:GameObject;
function OnGUI ()
//GUI.skin=uiskin;
{
if(GUI.Button(Rect(Screen.width/2+150,Screen.height/2+100,70,30),"camera1"));
{
print("you click camera2 button");
onActiveFalse();
camera1.active=true;
}
// GUI.skin=null;
if(GUI.Button(Rect(Screen.width/2+240,Screen.height/2+195,200,70),"camera2"));
{
onActiveFalse();
camera2.active=true;
} if(GUI.Button(Rect(200,200,73,33),"文字按钮"));
{
onActiveFalse();
camera3.active=true;
} if(GUI.Button(Rect(200,200,74,34),"文字按钮"));
{
onActiveFalse();
camera4.active=true;
}
}
function onActiveFalse()
{
camera1.active=false;
camera2.active=false;
camera3.active=false;
camera4.active=false;
拜谢大神