public virtual void Initialize() { SetTrackingOrigin(TBSettings.GetCameraSettings().trackingOrigin); TBCameraRig.instance.sortMode = TBSettings.GetDisplaySettings().opaqueSortMode; _camera.depthTextureMode = TBSettings.GetDisplaySettings().depthTextureMode; TBLogging.LogMessage("Opaque Sort Mode set to " + _camera.opaqueSortMode); _camera.allowHDR = false; }
/// <summary> /// Updates input readouts if necessary. /// </summary> public static void Update() { // Input Events are only executed if enabled in Input Settings. if (TBSettings.GetControlSettings().useInputEvents) { Events.UpdateEvents(); } }
protected void Update() { if (_baseCamera == null) { return; } if (UnityEngine.Input.GetKeyDown(TBSettings.GetCameraSettings().calibrationHotkey)) { _baseCamera.Recenter(); } }
public static void InitializeStartup() { // Initialize all required TButt components. switch (TBCore.GetActivePlatform()) { case VRPlatform.None: // On platforms where we have to first initialize the HMD, wait for that to finish before initializing TButt. TBCore.instance.StartCheckingForHMD(); break; default: TBLogging.LogMessage("TBCore is starting up..."); TBSettings.Initialize(); TBInput.Initialize(GetActivePlatform()); instance.InitializePerScene(); DontDestroyOnLoad(instance.gameObject); TBLogging.LogMessage("TBCore has finished starting up."); _initialized = true; break; } }
/// <summary> /// Returns 3DOF controller handedness as reported by the active SDK (Left, Right, or Center). /// </summary> /// <returns></returns> public static Mobile3DOFHandedness Get3DOFHandedness() { // In the editor, override hardware settings with whatever is set in the TButt Input Settings tool. if (TBCore.UsingEditorMode()) { if (TBSettings.GetControlSettings().handedness3DOF == TBSettings.TBHardwareHandedness.Left) { return(Mobile3DOFHandedness.Left); } else { return(Mobile3DOFHandedness.Right); } } if (_hasActiveSDK) { return(_activeSDK.Get3DOFHandedness()); } else { return(TBInput.Mobile3DOFHandedness.Center); } }
/// <summary> /// Returns the active headset, if one has been initialized. /// </summary> /// <returns></returns> public static VRHeadset GetActiveHeadset() { return(TBSettings.GetActiveHeadset()); }
protected virtual void SetTrackingOrigin(TBSettings.TBTrackingOrigin origin) { // Use the predefined, uncalibrated height if headset doesn't support position tracking and tracking origin is floor. if (!HeadsetHasPositionTracking() && (origin == TBSettings.TBTrackingOrigin.Floor)) { TBCameraRig.instance.GetTrackingVolume().localPosition = new Vector3(0, TBSettings.GetCameraSettings().uncalibratedFloorHeight, 0); } }
/// <summary> /// Applies settings and adds required components for input to be detected based on the active platform. /// </summary> public static void Initialize(VRPlatform platform) { TBCore.OnUpdate += TBInput.Update; #if UNITY_EDITOR _activeControlType = TBSettings.GetControlSettings().defaultEditorControlType; #endif _hasActiveSDK = true; switch (platform) { case VRPlatform.OculusPC: case VRPlatform.OculusMobile: TBInputOculus.instance.Initialize(); TBCore.OnFixedUpdate += TBInputOculus.instance.FixedUpdate; TBCore.OnUpdate += TBInputOculus.instance.Update; _activeSDK = TBInputOculus.instance; break; case VRPlatform.SteamVR: TBInputSteamVR.instance.Initialize(); TBCore.OnFixedUpdate += TBInputSteamVR.instance.FixedUpdate; TBCore.OnUpdate += TBInputSteamVR.instance.Update; _activeSDK = TBInputSteamVR.instance; break; case VRPlatform.Daydream: TBInputGoogle.instance.Initialize(); TBCore.OnFixedUpdate += TBInputGoogle.instance.FixedUpdate; TBCore.OnUpdate += TBInputGoogle.instance.Update; _activeSDK = TBInputGoogle.instance; break; case VRPlatform.PlayStationVR: #if TB_HAS_UNITY_PS4 TBPSVRInput.instance.Initialize(); TBCore.OnFixedUpdate += TBPSVRInput.instance.FixedUpdate; TBCore.OnUpdate += TBPSVRInput.instance.Update; _activeSDK = TBPSVRInput.instance; #else UnityEngine.Debug.LogError("TBInput attempted to initialize for PSVR, but the PSVR module is not available. Is the module installed and set up with #TB_HAS_UNITY_PS4?"); #endif break; case VRPlatform.WindowsMR: TBWindowsMRInput.instance.Initialize(); TBCore.OnFixedUpdate += TBWindowsMRInput.instance.FixedUpdate; TBCore.OnUpdate += TBWindowsMRInput.instance.Update; _activeSDK = TBWindowsMRInput.instance; break; default: _hasActiveSDK = false; UnityEngine.Debug.LogError("Attempted to initialize TBInput without an active SDK in TBCore. This shouldn't happen if TBCore exists in your scene."); break; } TBLogging.LogMessage("Active Control Type: " + _activeControlType); if (_activeControlType == ControlType.None) { TBLogging.LogMessage("No active control type is assigned to TBInput. Input for type 'active' will be ignored until a control type is assigned."); } }
public static void Initialize() { if (_nodes != null) { _nodes.Clear(); } // Add tracked controller nodes under the camera rig if we need them. if (TBSettings.GetControlSettings().supportsHandControllers) { switch (TBCore.GetActivePlatform()) { case VRPlatform.OculusPC: case VRPlatform.SteamVR: case VRPlatform.PlayStationVR: case VRPlatform.WindowsMR: AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); break; case VRPlatform.OculusMobile: if (TBInput.GetControllerModel(TBInput.Controller.RHandController) != VRController.None) { AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); } break; case VRPlatform.Daydream: if (TBInput.GetControllerModel(TBInput.Controller.RHandController) != VRController.None) { AddTrackedDeviceForNode(UnityEngine.XR.XRNode.LeftHand); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.RightHand); } break; default: break; } } if (TBSettings.GetControlSettings().supports3DOFControllers) { if (TBInput.GetControllerModel(TBInput.Controller.Mobile3DOFController) != VRController.None) { TBCameraRig.instance.GetTrackingVolume().gameObject.AddComponent <TB3DOFArmModel>().Initialize(); AddTrackedDeviceForNode(UnityEngine.XR.XRNode.GameController); } } if (TBSettings.GetControlSettings().supportsGamepad) { switch (TBCore.GetActivePlatform()) { case VRPlatform.PlayStationVR: AddTrackedDeviceForNode(UnityEngine.XR.XRNode.GameController); break; default: break; } } }