TBCameraRig

A universal rig for VR games that syncs settings across the camera from each platform’s SDK.

Overview

TBCameraRig uses Unity’s native VR integration while simultaneously exposing the platform-specific functionality of all the various SDKs

Dependencies

  • The scene contains a TBCore object
  • At least one platform is enabled in the TBCore Settings menu

Setup

Create a camera in your scene. Add a TBCameraRig script to it. That’s it! This is now your VR camera on whatever platform you’re on. Depending on your project, you may want to make a prefab out of it, or tag it as the Main Camera.

Reference

Get the TButt namespace to reference TBCameraRig in your scripts. Access functions and values through TBCameraRig.instance.

using TButt;

Camera Settings

Whenever you want to change camera settings, change them in the inspector or on TBCameraRig.instance in code. Its properties are named to match the properties in Unity’s standard Camera class:

Property Variable
Clear Flags CameraClearFlag clearFlags
Culling Mask LayerMask cullingMask
Background Color Color backgroundColor
Near Clip Plane float nearClipPlane
Far Clip Plane float farClipPlane
Use Occlusion Culling bool useOcclusionCulling

Example usage:

TBCameraRig.instance.backgroundColor = Color.black;
TBCameraRig.instance.farClipPlane = 200;

GetAudioListener()

Gets the Unity AudioListener associated with the camera.

Heads-up: At runtime, any AudioListener attached to the camera will be moved to a new GameObject that follows the camera’s position and rotation, so be careful to avoid assumptions that the AudioListener component lives on the same GameObject as the Camera component.. This works around compatibility issues with camera scale and popular audio spatializers.

Camera Object References

You can get the following references to active objects and transforms through TBCameraRig.instance:

Function Description
Camera GetCenterEyeCamera() Returns the VR camera.
Transform GetTrackingVolume() Returns a transform positioned at the center of the player’s tracking volume.
Transform GetCenter() Returns a transform that matches the camera’s position and orientation.
AudioListener GetAudioListener() Returns the AudioListener following the camera’s position and orientation.

Events

Events for changes to most camera settings - such as changes to clear flags - can be subscribed to through TBCameraRig.Events.