Пример #1
0
 /// <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();
     }
 }
Пример #2
0
        /// <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);
            }
        }
Пример #3
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.");
            }
        }
Пример #4
0
        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;
                }
            }
        }