To preview controller interactions within Unity, you will need to pair your controller to the Editor!
- You will need to Switch Platforms to PC Mac & Linux Standalone
- Ensure that bluetooth is enabled
- The Editor searches for the controller and automatically pairs. To auto pair, press play mode, turn on the controller and tap both buttons on the remote simultaneously (for more information and images of this process, see the Pairing the Mira Prism Remote to OSX and iOS page
If you are having trouble pairing the remote, please read the full Pairing the Prism Remote page
You'll notice that as you move your controller, the BTController GameObject matches the controller's rotation!
Start/Home Button Recentering
If you quickly press the Home//Start button during play mode, the Mira camera system and controller will reorient to the direction you're facing!
Now that your controller is connected, let's get some data from it! To start, make sure you have a Unity Event System, with the Mira Input Module
Make sure the Mira Input Module is above other input modules in the inspector panel
Open the 102_ControllerInteractions scene in Unity. You’ll find several examples of how to interact and control objects with the Mira Controller.
For an example of how to interact with standard Unity UI, navigate the scene hierarchy to MiraWikiTracking > HeadOrientation > Canvas Example. Simply adding both the Mira Graphic Raycast script to the canvas, and the MiraInputModule to the EventSystem enables this functionality. For more information see Controller Interaction and Events.
For an example of how to access the state of the controller via C#, open the DebugMiraController script, located in scene hierarchy at MiraWikiTracking > HeadOrientation > Canvas Debug Controller.
DebugMiraController implements the Unity Event System’s callback functions: OnPointerEnter,OnPointerExit OnPointerClick, OnPointerDown, and OnPointerUp. They can be used to execute code when the controller interacts with your game objects. Also, in this script you can find a full list of MiraController’s properties, like MiraController.Orientation and MiraController.StartButtonPressed. These properties can be used to get information about the current controller state.
MiraController is used to provide information about the controller’s state to your Unity program. To access the controller state via code, simply write MiraController.Position or MiraController.BackButtonPressed. For a full list of properties see our API documentation
For an example of how to create an interactive game object using the Event System callback functions via C#, open the MiraExampleInteraction script located in scene hierarchy at MiraWikiTracking > HeadOrientation > Solar System > lowpoly_planet Interaction Example.
This script uses the Unity Event System’s callback functions to create a talking planet that responds when clicked on. The state of the planet is represented by the variables isPlanetFeelingSatisfied, timeSinceLastInteraction, isUserPointingAtPlanet. These states are changed by pointer events, causing the planet to get impatient or thank users for clicking on it.
For an example of how to grab and move a game object using the Event System callback functions via C#, open the MiraGrabExample script which is located in scene hierarchy at MiraWikiTracking > HeadOrientation > Solar System > lowpoly_planet Grab Example.
This script uses the Unity Event System’s callback functions to reposition a GameObject using the controller and the touch pad.
This example is very similar to the previous grab example except that it works with game objects that use Unity’s physics simulation system. The primary difference is that the MiraPhysicsGrabExample temporarily disables the physics simulation on the object users are manipulating. This prevents chaotic feedback loops in the physics simulation. Open the MiraPhysicsGrabExample script which is located in scene hierarchy at MiraWikiTracking > HeadOrientation > Physics Sandbox .
Now that you've mastered the controller, it's time to learn how to track!