The XRTK is meant to be a replacement to the Unity XR Management system, and it is advised not to mix and match the two.
Currently the Magic Leap platform requires the Magic Leap XR Plugin to actually make builds for the platform, the intention is to be fully independent of the Unity XR Management System in the future.
We recommend walking through the Getting Started Guide for a detailed understanding to get up and running.
However, here is the TL;DR short version:
- Create a new Unity Project
- Setup the Legacy XR settings in "Edit -> Project Settings -> Player -> XR Settings" for your current and any other platforms you want to run on
- Add the XRTK UPM registry to Unity by Opening the Unity Package Manager (
Window -> Package manager
), selecting theAdvanced
drop down and clicking onAdvanced Project Settings
, then Adding the following details:Name: XRTK
Scope(s): com.xrtk
- Return to the Unity Package manager and select
My Registries
in the Sources) dropdown (next to the+
symbol) - Select the XRTK.SDK and click Install
- Close the Unity Package Manager and return to your scene
- Select or create the scene you want to create Mixed Reality Content in
- Select
Mixed Reality Toolkit -> Configure
in the Unity Menu. THis will update your scene and add the MixedRealityToolkit instance. - Done, you can now run your project for Windows Standalone
- If you wish, you can install additional platforms, such as Oculus or Windows Mixed Reality from the Package Manager. once installed they will prompt to install their platform configuration in to your project (ENSURE that you have your Mixed Reality Scene open)
- Provided you have configured the XR SDK settings for each platform correctly, the project will run
In short NONE, Once you import the default configuration, then the project will be available to run on any of the supported platforms, the only exceptions are:
- For Quest on Android, you will also need to install an Android Manifest in to your project using
Mixed Reality Toolkit -> Tools -> Oculus -> Create Oculus Quest compatible AndroidManifest.xml
in the Editor menu to ensure the Android build properly targets the Quest. - For Magic Leap, you will need to install the ML assets/XR package and follow Magic Leaps instructions for setting up the device. You will also need an AndroidManifest.xml file for the Magic Leap.
The only systems which are Mandatory are the Camera System
and the Input System
. All other systems can be safely disabled if you wish and only enabled when you need them.
The Playspace is dynamically updated during edit/run time to meet the needs of the platform it is running on by the Camera system. If it is not being updated, check your Camera Settings
are configured for your current platform. There must be a Camera System configured for the current Runtime platform and/Or the editor.
The Default Camera system installed with the SDK should cover Windows Standalone and most other platforms, however check that its Runtime Platforms
is configured correctly (and is present)
Other platforms will install their own Camera Systems as required.
For any object to be Interactable
in a Mixed Reality scene, it must:
- Have been registered with the
InputSystem
as a tracked object usingThe XRTK provides a handy base class calledMixedRealityToolkit.InputSystem.Register(gameObject);
BaseInputHandler
for tracked scene objects - Have a collider component added and configured relative to the objects dimensions.
If you are using
Physics Layers
, then ensure the layers used for your objects match those in the Input System configuration
The Input System events have a concept called Used
, this allows for scenarios where you want multiple scripts to receive an event and control when the chain of events to end. If you want any object to stop and event from propagating then you simply need to handle the Used
property.
You should also check if an event is already used in your scripts before executing them.
Here is a sample script:
public class MyEventScript : BaseInputHandler, IMixedRealityInputHandler
{
[SerializeField]
private MixedRealityInputAction myAction = MixedRealityInputAction.None;
public void OnInputDown(InputEventData eventData)
{
if (eventData.used)
{
return;
}
if (eventData.MixedRealityInputAction.Id == myAction.Id)
{
// Do something cool as the user pressed a button on this object
eventData.used = true;
}
}
}
In this script we use the BaseInputHandler
to register the object in the scene and the IMixedRealityInputHandler
to listen for Input Events. When an InputDown
event is received:
- We check if the event has already been used by another script
- We check if the Input Action configured for this script has been detected by the event
- If the action we were expecting happens and the event hasn't been used already, we perform something and then update the
Used
property of the event toTrue
to stop other scripts using.
This patten is very useful if you have multiple scripts attached to an object which perform different things based on the status of the object but only want ONE to work at a time.
The inverse is also true, if you skip checking for Used
you can have things run regardless.