When using a VR headset like the Meta Quest 3, controllers can be a key component to interacting and controlling your scene. When developing in Unity, you may want to provide the user with interactions through Buttons or Toggles. You may also want to provide them interactions and controls through their controller. Meta Building Blocks contains a Controller Buttons Mapper that helps the developer assign controls to specific buttons.
Controller buttons are a great alternative to having buttons or toggles be clicked in game to lead to an action. Unity buttons and toggles are not always the most straightforward object to implement and controller buttons may work better for your scene. As the controller buttons mapper is a Building Block, it is directly compatible with the other building blocks, and leads to ease when developing. Make sure to remember that for most controller commands you create, you will also want an inverse controller command to reset, pause, or turn off that ability as well. This is especially helpful for setting an object active and inactive.
Meta Quest 3
Device setup for developing:
Unity installed
Additional set up tutorial: Set up Unity for XR development
Meta XR All-in-One SDK installed
Add as an asset to your Unity account
Once in Unity, navigate to Package Manager and install All-in-One SDK
This tutorial is to set a controller button click to make a game object visible and not visible in a scene. Many more actions are possible with controller mapping, this is an example of one of them.
In your menu, select Meta > Tools > Building Blocks.
The Meta Building Blocks will appear in a pop up window, scroll through the options to find Controller Buttons Mapper or search for it in the search bar. Add the building block to your scene.
Select the building block within your Hierarchy. Go to the Inspector to Button Click Actions. This is where you decide what buttons will lead to what actions.
To make a game object appear based on a button click, select the button that will be pressed for it to appear. Under Callback(), add the game object. Then, set the function as GameObject.SetActive. This is a boolean. You will need to check the box that appears next to the game object in Callback().
To make the game object disappear, select the button that will be pressed for this action to occur. Make sure it is a different button than the one used for making the object appear. Repeat the same steps as 4 but this time, after setting the function as GameObject.SetActive, do NOT check the box.
Test out the scene to make sure the game object is correctly appearing and disappearing.
If you would like the game object to start the scene as hidden (or not active), go to the game object in the Hierarchy. Go to the Inspector and uncheck the check mark box to the left of the object's name.
Additional methods to have controller mapping in Unity