66 [Obsolete(
"primaryWandSettings is deprecated, please update to use left/right based on user preference instead.")]
68 [Obsolete(
"secondaryWandSettings is deprecated, please update to use left/right based on user preference instead.")]
75 #pragma warning disable 618
76 get => secondaryWandSettings;
77 set => secondaryWandSettings = value;
78 #pragma warning restore 618
85 #pragma warning disable 618
86 get => primaryWandSettings;
87 set => primaryWandSettings = value;
88 #pragma warning restore 618
110 public EditorSettings editorSettings =
new EditorSettings();
114 private bool needsDriverUpdateNotifiedOnce =
false;
115 private bool needsDriverUpdateErroredOnce =
false;
131 graphicsSettings.applicationTargetFramerate = Application.targetFrameRate;
132 graphicsSettings.applicationVSyncCount = QualitySettings.vSyncCount;
134 if (!SystemControl.SetPlatformContext())
136 Log.
Warn(
"Failed to set application context.");
140 if (!SystemControl.SetApplicationInfo())
142 Log.
Warn(
"Failed to send application info to the T5 Service.");
146 RefreshPlayerSettings();
149 spectatorSettings.glassesMirrorMode =
glassesSettings.glassesMirrorMode;
150 spectatorSettings.spectatedPlayer = playerSettings.PlayerIndex;
153#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
157 private void OnBeforeUpdate()
160 if (UnityEditor.EditorApplication.isPaused)
165 if (
Player.scanningForPlayers)
170 Player.ScanForNewPlayers();
171 Wand.GetLatestInputs();
176 if (UnityEngine.InputSystem.LowLevel.InputState.currentUpdateType != UnityEngine.InputSystem.LowLevel.InputUpdateType.BeforeRender)
188#if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
190 Player.ScanForNewPlayers();
191 Wand.GetLatestInputs();
193 RefreshPlayerSettings();
194 RefreshSpectatorSettings();
199 if (Glasses.TryGetPreviewPose(spectatedPlayer, out var spectatedPlayerPose))
202 spectatedPlayerPose.position,
203 spectatedPlayerPose.rotation);
206#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
207 var devices = InputUser.GetUnpairedInputDevices();
208 if (devices.Count > 0)
210 foreach (InputDevice dev
in devices)
212 if (dev is WandDevice)
214 var headPoseRoot = Glasses.GetPoseRoot(((WandDevice)dev).playerIndex);
216 if (headPoseRoot !=
null)
218 var playerInput = headPoseRoot.GetComponentInChildren<PlayerInput>();
220 if (playerInput !=
null && playerInput.user.valid)
222 Log.Warn($
"Unpaired Wand Device [{((WandDevice)dev).ControllerIndex}] found and paired to Player [{((WandDevice)dev).playerIndex}].");
223 InputUser.PerformPairingWithDevice(dev, playerInput.user);
224 playerInput.user.ActivateControlScheme(
"XR");
249 private void GetLatestPoseData()
269 if (!needsDriverUpdateErroredOnce)
278 if (!needsDriverUpdateNotifiedOnce)
280 Log.
Warn(
"Incompatible Tilt Five service. Please update driver package.");
281 needsDriverUpdateNotifiedOnce =
true;
287 needsDriverUpdateNotifiedOnce =
false;
291 catch (System.DllNotFoundException e)
294 "Could not connect to Tilt Five plugin for compatibility check: {0}",
296 needsDriverUpdateErroredOnce =
true;
298 catch (System.Exception e)
301 needsDriverUpdateErroredOnce =
true;
313 private void OnEnable()
317 NativePlugin.SetMaxDesiredGlasses((
byte)GetSupportedPlayerCount());
319 catch (System.DllNotFoundException e)
322 "Could not connect to Tilt Five plugin for setting max glasses: {0}",
325 catch (System.Exception e)
327 Log.Error(e.Message);
332#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
333 InputSystem.onBeforeUpdate += OnBeforeUpdate;
337 private void OnDisable()
339#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
340 InputSystem.onBeforeUpdate -= OnBeforeUpdate;
345 private void OnDestroy()
350 private void OnApplicationQuit()
360 private static void Quit()
364 NativePlugin.UnloadWorkaround();
366 catch (System.DllNotFoundException)
370 catch (System.Exception e)
372 Log.Error(e.Message);
376 [RuntimeInitializeOnLoadMethod]
377 private static void RunOnStart()
379 Application.quitting += Quit;
382 private void RefreshSpectatorSettings()
387 Log.Warn(
"No camera template detected in TiltFiveManager's glassesSettings. A camera template is required.");
394 spectatorSettings.glassesMirrorMode =
glassesSettings.glassesMirrorMode;
397 var highestSupportedPlayer = (
PlayerIndex)GetSupportedPlayerCount();
400 Log.Warn($
"Invalid spectatorSettings.spectatedPlayer [{spectatorSettings.spectatedPlayer}]. TiltFiveManager only supports one player.");
401 spectatorSettings.spectatedPlayer = highestSupportedPlayer;
405 private void RefreshPlayerSettings()
424 if(playerSettings ==
null)
464 scaleSettings.contentScaleRatio = Mathf.Clamp(
scaleSettings.contentScaleRatio, ScaleSettings.MIN_CONTENT_SCALE_RATIO,
float.MaxValue);
476 if (playerSettings !=
null)
478 RefreshPlayerSettings();
483 RefreshSpectatorSettings();
500 #region ISceneInfo Implementation
502 [Obsolete(
"TiltFiveManager.GetScaleToUWRLD_UGBD is deprecated. Please use TiltFiveManager.GetScaleToWorldSpaceFromGameboardSpace instead.")]
503 public float GetScaleToUWRLD_UGBD() {
return GetScaleToWorldSpaceFromGameboardSpace(); }
505 public float GetScaleToWorldSpaceFromGameboardSpace()
510 public Pose GetGameboardPose()
515 public Camera GetEyeCamera()
520 public uint GetSupportedPlayerCount()
525 public bool IsActiveAndEnabled()
527 return isActiveAndEnabled;
530 #endregion ISceneInfo Implementation