三维图像库与下一个和上一个按钮-Vuforia虚拟按钮



我正在创建一个带有虚拟按钮的三维图像库。目前使用vuforia站点的虚拟按钮示例,我能够为单个图像实现每个按钮。我只想创建两个按钮来使用虚拟按钮进行导航。我该怎么办。

下面的代码没有经过测试,但应该很容易插入C#脚本,编辑器会指出您可能会收到的警告,并建议简单的修复方法。

List<Texture> MyImageList = new List<Texture>();
int imageIndex = 0;
void OnGUI() {
   GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), MyImageList[imageIndex]);
   if(GUI.Button(new Rect(10,10,80,10), "Prev")) {
      Prev();
   }
   if(GUI.Button(new Rect(200,10,80,10), "Next")) {
      Next();
   }
}
void Next() {
     if(imageIndex < MyImageList.Count)
        imageIndex++; else imageIndex = 0;
}
void Prev() {
     if(imageIndex > MyImageList.Count)
        imageIndex--; else imageIndex = MyImageList.Count;
}

它本身不是一个虚拟按钮,但使用全局列表索引器是最好的选择,如上所述。

相关内容

最新更新