The unified Future Reality Lab library for XR systems in Unity.
Either download and unpack the .zip, or clone this repo directly into the Assets
folder of your Unity project.
cd ./Assets/
git clone https://github.com/futurerealitylab/FRL.XR.git
PLEASE SEE TEMPORARY HOTFIX BELOW.
Drag the XRPlayer
prefab into your scene. Then, look at the XRManager
Component:
There are four supported SDKs: Wave
, OVR
, SteamVR
, and Daydream
. Windows Mixed Reality
is technically supported without an SDK, but requires Windows 10 Fall Creators edition. Select the SDKs you plan on using. There will be compilation errors if you select an SDK and don't have it installed in your Unity project. Once you've selected the SDKs, change the System
field to match the system you want to use.
Please add the following pre-compiler definitions to your project depending on which platform(s) you are developing for:
WaveVR: WAVE
OVR: OVR
SteamVR: STEAM_VR
Daydream: DAYDREAM
If you have custom models for your controllers, you can put them under the XRController
GameObjects found under XRManager
.
In order for a GameObject to receive input when it is being pointed at, it needs a component which implements one of the Pointer
interfaces, and a Collider
component.
In order for a GameObject to receive input globally (whenever any button is pressed), it needs a Receiver
component and a component which implements one of the Global
interfaces. If the module
field of the Receiver
component is populated with one of the XRControllerModule
or HMDModule
components found on the XRHMD
and XRController
GameObjects, that GameObject will only receive global input from that specific module. Otherwise, the GameObject will receive input from all input modules.
Here is an example implementation of a GameObject receiving global and pointer inputs.
using UnityEngine;
using FRL.IO;
[RequireComponent(typeof(Receiver))]
public class ExampleInput : MonoBehaviour, IPointerTriggerPressDownHandler, IGlobalTouchpadTouchHandler {
private Renderer objectRenderer;
void Awake() {
objectRenderer = GetComponent<Renderer>();
}
private void SetColor(Color color) {
Debug.Log("Setting Color to: " + color);
objectRenderer.material.color = color;
}
public void OnPointerTriggerPressDown(XREventData eventData) {
//This will only be called when the object is being pointed at by a controller.
Color color = (eventData.hand == XRHand.Left ? Color.blue : Color.red);
SetColor(color);
}
public void OnGlobalTouchpadTouch(XREventData eventData) {
//This will be called whenever any touchpad is touched.
Debug.Log("My " + eventData.hand + " hand is touching the Touchpad!");
}
}
The full set of supported interfaces can be found in the FRL/IO/Interfaces/Interfaces.cs
class.
This is an actively developed, open source library. Please feel free to log issues and feedback! It helps us make the library better for you.
Copyright 2018 NYU Future Reality lab
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.