【发布时间】:2015-07-29 15:29:09
【问题描述】:
我的脚本有问题。我需要通过 2 个按钮切换一组摄像头。但我的柜台有问题。当我尝试前后更换相机时,它无法正常工作。
public void Pressed () {
if (Next == true) {
currCamIndex ++;
Debug.Log ("index = " + currCamIndex);
if (currCamIndex < cameras.Length) {
cameras [currCamIndex - 1].gameObject.SetActive (false);
cameras [currCamIndex].gameObject.SetActive (true);
} else {
cameras [currCamIndex - 1].gameObject.SetActive (false);
currCamIndex = 0;
cameras [currCamIndex].gameObject.SetActive (true);
}
}
if (Prev == true) {
currCamIndex --;
if (currCamIndex >= 0) {
cameras [currCamIndex + 1].gameObject.SetActive (false);
cameras [currCamIndex].gameObject.SetActive (true);
} else {
cameras [currCamIndex + 1].gameObject.SetActive (false);
currCamIndex = cameras.Length-1;
cameras [currCamIndex].gameObject.SetActive (true);
}
}
if (Back == true) {
Application.LoadLevel(0);
}
【问题讨论】:
标签: camera unityscript