主要是控制功能太多且不能同时赋予一个物体,如tap to place, bounds control,object manipulator写到一个例子中,用button控制开关省事,顺便上一节的路标Chevron也开关控制一下试试。
参考官网:Exercise - Panel of buttons and dynamic menus - Learn | Microsoft Docs
1. Create Empty,name the object Buttons,
2.use the Add Component button to add the GridObjectCollection component and configure it as follows:
上面的喇叭太烦人了,挡视野,点击Gizmos按钮解决了。如下:
3.In the Project window, navigate to the Assets > MRTK.Tutorials.GettingStarted > Prefabs folder, click-and-drag the PressableRoundButton prefab on to the Buttons object, then right-click on the PressableRoundButton and select Duplicate to create a copy, repeat until four.全部改名字如下图。
Then In the Hierarchy window, 选择buttons选项,click the Update Collection button to update the position of the Buttons,按钮自动如上图排列。
4..For each button, select the SeeItSayItLabel > TextMeshPro child object, then in the Inspector window, change the respective TextMeshPro - Text component text to match the button names:
5.In the Hierarchy window, select the indicator button object, then in the Inspector window, configure the Interactable.OnClick () event as follows:
Chevron设置如下,add compoment 添加了Directionalindicator函数,不能勾:
Directionalindicator函数位置如下:
按钮添加函数过程如下两图:
勾上勾。
6.tap to place 添加一个函数,控制cube,如下图:
7. manipulate enable添加两个函数,控制cube,如下,记得勾上: