Tilt Five Unity API  1.3.0
Public Member Functions | Public Attributes | Protected Member Functions | Properties | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TiltFive.TiltFiveManager Class Reference

The Tilt Five manager. More...

Inheritance diagram for TiltFive.TiltFiveManager:
TiltFive.SingletonComponent< TiltFiveManager > TiltFive.ISceneInfo

Public Member Functions

bool NeedsDriverUpdate ()
 Check if a driver update is needed. More...
 
float GetScaleToUWRLD_UGBD ()
 
Pose GetGameboardPose ()
 
Camera GetEyeCamera ()
 
uint GetSupportedPlayerCount ()
 
bool IsActiveAndEnabled ()
 

Public Attributes

ScaleSettings scaleSettings
 The scale conversion runtime configuration data. More...
 
GameBoardSettings gameBoardSettings
 The game board runtime configuration data. More...
 
GlassesSettings glassesSettings
 The glasses runtime configuration data. More...
 
WandSettings primaryWandSettings
 
WandSettings secondaryWandSettings
 
SpectatorSettings spectatorSettings = new SpectatorSettings()
 The spectator camera's runtime configuration data. More...
 
LogSettings logSettings = new LogSettings()
 The log settings. More...
 

Protected Member Functions

override void Awake ()
 Awake this instance. More...
 

Properties

WandSettings leftWandSettings [get, set]
 The wand runtime configuration data for the left hand wand. More...
 
WandSettings rightWandSettings [get, set]
 The wand runtime configuration data for the right hand wand. More...
 
- Properties inherited from TiltFive.SingletonComponent< TiltFiveManager >
static T Instance [get]
 

Private Member Functions

void Update ()
 Update this instance. More...
 
void LateUpdate ()
 Update this instance after all components have finished executing their Update() functions. More...
 
void GetLatestPoseData ()
 Obtains the latest pose for all trackable objects. More...
 
void OnEnable ()
 Called when the GameObject is enabled. More...
 
void OnDisable ()
 
void OnDestroy ()
 
void OnApplicationQuit ()
 
void RefreshSpectatorSettings ()
 
void RefreshPlayerSettings ()
 

Static Private Member Functions

static void Quit ()
 
static void RunOnStart ()
 

Private Attributes

bool needsDriverUpdateNotifiedOnce = false
 
bool needsDriverUpdateErroredOnce = false
 
PlayerSettings playerSettings = new PlayerSettings()
 

Detailed Description

The Tilt Five manager.

Definition at line 45 of file TiltFiveManager.cs.

Member Function Documentation

◆ Awake()

override void TiltFive.TiltFiveManager.Awake ( )
protectedvirtual

Awake this instance.

Reimplemented from TiltFive.SingletonComponent< TiltFiveManager >.

Definition at line 117 of file TiltFiveManager.cs.

118  {
119  base.Awake();
120 
121  // Apply log settings
124 
126  {
127  Log.Warn("Failed to send application info to the T5 Control Panel.");
128  enabled = false;
129  }
130 
132 
136  }
static bool SetApplicationInfo()
Definition: Display.cs:144
Camera cameraTemplate
The camera used as a template for creating the eye cameras at runtime.
GlassesMirrorMode glassesMirrorMode
The Logger.
Definition: Log.cs:42
static void Warn(string m, params object[] list)
WARN logging function call.
Definition: Log.cs:166
static int LogLevel
Gets or sets the logging level.
Definition: Log.cs:68
static string TAG
Gets or sets the logging tag.
Definition: Log.cs:58
PlayerIndex spectatedPlayer
The player that will have their perspective mirrored on screen.
GlassesMirrorMode glassesMirrorMode
The spectator camera will display content on screen depending on the mirroring mode....
Camera spectatorCamera
The camera used for rendering the onscreen preview
LogSettings logSettings
The log settings.
SpectatorSettings spectatorSettings
The spectator camera's runtime configuration data.
PlayerSettings playerSettings
GlassesSettings glassesSettings
The glasses runtime configuration data.

References TiltFive.GlassesSettings.cameraTemplate, TiltFive.GlassesSettings.glassesMirrorMode, TiltFive.SpectatorSettings.glassesMirrorMode, TiltFive.TiltFiveManager.glassesSettings, TiltFive.Logging.LogSettings.level, TiltFive.Logging.Log.LogLevel, TiltFive.TiltFiveManager.logSettings, TiltFive.PlayerSettings.PlayerIndex, TiltFive.TiltFiveManager.playerSettings, TiltFive.TiltFiveManager.RefreshPlayerSettings(), TiltFive.Display.SetApplicationInfo(), TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager.spectatorSettings, TiltFive.Logging.LogSettings.TAG, TiltFive.Logging.Log.TAG, and TiltFive.Logging.Log.Warn().

◆ GetEyeCamera()

Camera TiltFive.TiltFiveManager.GetEyeCamera ( )

Implements TiltFive.ISceneInfo.

Definition at line 463 of file TiltFiveManager.cs.

464  {
465  return Glasses.GetLeftEye(PlayerIndex.One);
466  }
The Glasses API and runtime.
Definition: Glasses.cs:35
static Camera GetLeftEye(PlayerIndex playerIndex)
Definition: Glasses.cs:287
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

References TiltFive.Glasses.GetLeftEye().

◆ GetGameboardPose()

Pose TiltFive.TiltFiveManager.GetGameboardPose ( )

Implements TiltFive.ISceneInfo.

Definition at line 458 of file TiltFiveManager.cs.

459  {
460  return new Pose(gameBoardSettings.gameBoardCenter, Quaternion.Euler(gameBoardSettings.gameBoardRotation));
461  }
Vector3 gameBoardRotation
The game board rotation or focal rotational offset.
Vector3 gameBoardCenter
The game board position or focal position offset.
GameBoardSettings gameBoardSettings
The game board runtime configuration data.

References TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.GameBoardSettings.gameBoardRotation, and TiltFive.TiltFiveManager.gameBoardSettings.

◆ GetLatestPoseData()

void TiltFive.TiltFiveManager.GetLatestPoseData ( )
private

Obtains the latest pose for all trackable objects.

Definition at line 199 of file TiltFiveManager.cs.

200  {
204  }
static void Update(GlassesSettings glassesSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings)
Updates this T:TiltFive.Glasses.
Definition: Glasses.cs:201
WandSettings rightWandSettings
The wand runtime configuration data for the right hand wand.
ScaleSettings scaleSettings
The scale conversion runtime configuration data.
WandSettings leftWandSettings
The wand runtime configuration data for the left hand wand.
The Wand API and runtime.
Definition: Wand.cs:55
static void Update(WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, PlayerIndex playerIndex=PlayerIndex.One)
Definition: Wand.cs:151

References TiltFive.TiltFiveManager.gameBoardSettings, TiltFive.TiltFiveManager.glassesSettings, TiltFive.TiltFiveManager.leftWandSettings, TiltFive.TiltFiveManager.rightWandSettings, TiltFive.TiltFiveManager.scaleSettings, TiltFive.Glasses.Update(), and TiltFive.Wand.Update().

◆ GetScaleToUWRLD_UGBD()

float TiltFive.TiltFiveManager.GetScaleToUWRLD_UGBD ( )

Implements TiltFive.ISceneInfo.

Definition at line 453 of file TiltFiveManager.cs.

454  {
456  }
float gameBoardScale
The game board's scale multiplies the perceived size of objects in the scene.
float GetScaleToUWRLD_UGBD(float gameboardScale)

References TiltFive.GameBoardSettings.gameBoardScale, TiltFive.TiltFiveManager.gameBoardSettings, TiltFive.ScaleSettings.GetScaleToUWRLD_UGBD(), and TiltFive.TiltFiveManager.scaleSettings.

◆ GetSupportedPlayerCount()

uint TiltFive.TiltFiveManager.GetSupportedPlayerCount ( )

Implements TiltFive.ISceneInfo.

Definition at line 468 of file TiltFiveManager.cs.

469  {
470  return 1; // TODO: Change this if we decide to include spectators with TiltFiveManager
471  }

Referenced by TiltFive.TiltFiveManager.OnEnable(), and TiltFive.TiltFiveManager.RefreshSpectatorSettings().

◆ IsActiveAndEnabled()

bool TiltFive.TiltFiveManager.IsActiveAndEnabled ( )

Implements TiltFive.ISceneInfo.

Definition at line 473 of file TiltFiveManager.cs.

474  {
475  return isActiveAndEnabled;
476  }

◆ LateUpdate()

void TiltFive.TiltFiveManager.LateUpdate ( )
private

Update this instance after all components have finished executing their Update() functions.

Definition at line 187 of file TiltFiveManager.cs.

188  {
189  // Trackables should be updated just before rendering occurs,
190  // after all Update() calls are completed.
191  // This allows any Game Board movements to be finished before we base the
192  // Glasses/Wand poses off of its pose, preventing perceived jittering.
194  }
Provides access to player settings and functionality.
Definition: Player.cs:16

References TiltFive.TiltFiveManager.playerSettings, and TiltFive.TiltFiveManager.spectatorSettings.

◆ NeedsDriverUpdate()

bool TiltFive.TiltFiveManager.NeedsDriverUpdate ( )

Check if a driver update is needed.

Note that this can also return false if this has not yet been able to connect to the Tilt Five driver service (compatibility state unknown), so this may need to be called multiple times in that case. This only returns true if we can confirm that the driver is incompatible.

If it is necessary to distinguish between unknown and compatible, use GetServiceCompatibility directly.

Definition at line 217 of file TiltFiveManager.cs.

218  {
220  {
221  try
222  {
224  bool needsUpdate = compatibility == ServiceCompatibility.Incompatible;
225 
226  if (needsUpdate)
227  {
229  {
230  Log.Warn("Incompatible Tilt Five service. Please update driver package.");
232  }
233  }
234  else
235  {
236  // Not incompatible. Reset the incompatibility warning.
238  }
239  return needsUpdate;
240  }
241  catch (System.DllNotFoundException e)
242  {
243  Log.Info(
244  "Could not connect to Tilt Five plugin for compatibility check: {0}",
245  e.Message);
247  }
248  catch (System.Exception e)
249  {
250  Log.Error(e.Message);
252  }
253  }
254 
255  // Failed to communicate with Tilt Five plugin at some point, so don't know whether
256  // an update is needed or not. Just say no.
257  return false;
258  }
static void Info(string m, params object[] list)
INFO logging function call.
Definition: Log.cs:140
static void Error(string m, params object[] list)
ERROR logging function call.
Definition: Log.cs:127
static ServiceCompatibility GetServiceCompatibility()
ServiceCompatibility
Whether the running service is compatible.

References TiltFive.Logging.Log.Error(), TiltFive.NativePlugin.GetServiceCompatibility(), TiltFive.Logging.Log.Info(), TiltFive.TiltFiveManager.needsDriverUpdateErroredOnce, TiltFive.TiltFiveManager.needsDriverUpdateNotifiedOnce, and TiltFive.Logging.Log.Warn().

Referenced by TiltFive.TiltFiveManager.Update().

◆ OnApplicationQuit()

void TiltFive.TiltFiveManager.OnApplicationQuit ( )
private

Definition at line 301 of file TiltFiveManager.cs.

302  {
303  OnDisable();
304  }

References TiltFive.TiltFiveManager.OnDisable().

◆ OnDestroy()

void TiltFive.TiltFiveManager.OnDestroy ( )
private

Definition at line 296 of file TiltFiveManager.cs.

297  {
298  Player.OnDisable();
299  }

◆ OnDisable()

void TiltFive.TiltFiveManager.OnDisable ( )
private

Definition at line 288 of file TiltFiveManager.cs.

289  {
290 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
291  InputSystem.onBeforeUpdate -= OnBeforeUpdate;
292 #endif
293  Player.OnDisable();
294  }

Referenced by TiltFive.TiltFiveManager.OnApplicationQuit().

◆ OnEnable()

void TiltFive.TiltFiveManager.OnEnable ( )
private

Called when the GameObject is enabled.

Definition at line 263 of file TiltFiveManager.cs.

264  {
265  try
266  {
268  }
269  catch (System.DllNotFoundException e)
270  {
271  Log.Info(
272  "Could not connect to Tilt Five plugin for setting max glasses: {0}",
273  e.Message);
274  }
275  catch (System.Exception e)
276  {
277  Log.Error(e.Message);
278  }
279 
280  Player.OnEnable(GetSupportedPlayerCount());
282 
283 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
284  InputSystem.onBeforeUpdate += OnBeforeUpdate;
285 #endif
286  }
static void Reset(GlassesSettings glassesSettings, SpectatorSettings spectatorSettings=null, PlayerIndex playerIndex=PlayerIndex.None)
Reset this T:TiltFive.Glasses.
Definition: Glasses.cs:149
static void SetMaxDesiredGlasses(byte maxCount)

References TiltFive.Logging.Log.Error(), TiltFive.TiltFiveManager.GetSupportedPlayerCount(), TiltFive.TiltFiveManager.glassesSettings, TiltFive.Logging.Log.Info(), TiltFive.Glasses.Reset(), and TiltFive.NativePlugin.SetMaxDesiredGlasses().

◆ Quit()

static void TiltFive.TiltFiveManager.Quit ( )
staticprivate

Definition at line 311 of file TiltFiveManager.cs.

312  {
313  try
314  {
316  }
317  catch (System.DllNotFoundException)
318  {
319  // Nothing to report on quit if the plugin isn't present
320  }
321  catch (System.Exception e)
322  {
323  Log.Error(e.Message);
324  }
325  }
static void UnloadWorkaround()

References TiltFive.Logging.Log.Error(), and TiltFive.NativePlugin.UnloadWorkaround().

Referenced by TiltFive.TiltFiveManager.RunOnStart().

◆ RefreshPlayerSettings()

void TiltFive.TiltFiveManager.RefreshPlayerSettings ( )
private

Definition at line 356 of file TiltFiveManager.cs.

357  {
358  /* In an initial implementation of TiltFiveManager's internal PlayerSettings object, we initialized
359  * a new PlayerSettings in Awake() and set its internal settings objects to TiltFiveManager's internal settings objects.
360  *
361  * However, this introduced a bug. The settings values in TiltFiveManager's custom inspector couldn't be
362  * modified when the editor was in play mode, which would be a fairly significant quality of life issue for developers.
363  *
364  * I'm a bit fuzzy on the underlying mechanism, but the issue seemed to be that in the TiltFiveManager's
365  * custom inspector code, the SerializedProperty API (for GlassesSettings, WandSettings, ScaleSettings, etc)
366  * couldn't apply edits to the underlying settings objects if they were owned/shared by multiple parent classes
367  * (e.g. the same GlassesSettings can't be owned by both a TiltFiveManager and a PlayerSettings without
368  * breaking SerializedProperty's ability to modify the GlassesSettings).
369  *
370  * So the fix was to stop sharing.
371  * Instead of building a PlayerSettings internally on Awake() that uses TiltFiveManager's existing settings objects,
372  * we build one that has its own unique internal settings objects, and any time an edit gets made,
373  * OnValidate() does a shallow copy to those objects using RefreshPlayerSettings(). */
374 
375  if(playerSettings == null)
376  {
377  return;
378  }
380 
381  if (glassesSettings != null)
382  {
384  }
385  if (rightWandSettings != null)
386  {
388  }
389  if (leftWandSettings != null)
390  {
392  }
393  if (gameBoardSettings != null)
394  {
396  }
397  if (scaleSettings != null)
398  {
400  }
401  }
ScaleSettings scaleSettings
GameBoardSettings gameboardSettings
WandSettings leftWandSettings
GlassesSettings glassesSettings
WandSettings rightWandSettings

References TiltFive.PlayerSettings.gameboardSettings, TiltFive.TiltFiveManager.gameBoardSettings, TiltFive.PlayerSettings.glassesSettings, TiltFive.TiltFiveManager.glassesSettings, TiltFive.PlayerSettings.leftWandSettings, TiltFive.TiltFiveManager.leftWandSettings, TiltFive.PlayerSettings.PlayerIndex, TiltFive.TiltFiveManager.playerSettings, TiltFive.PlayerSettings.rightWandSettings, TiltFive.TiltFiveManager.rightWandSettings, TiltFive.PlayerSettings.scaleSettings, and TiltFive.TiltFiveManager.scaleSettings.

Referenced by TiltFive.TiltFiveManager.Awake().

◆ RefreshSpectatorSettings()

void TiltFive.TiltFiveManager.RefreshSpectatorSettings ( )
private

Definition at line 333 of file TiltFiveManager.cs.

334  {
335  // Warn developers if they've left the glassesSettings camera template field empty, since it's still required for the original TiltFiveManager
336  if(glassesSettings.cameraTemplate == null)
337  {
338  Log.Warn("No camera template detected in TiltFiveManager's glassesSettings. A camera template is required.");
339  }
340 
341  // We don't expose any global settings like SpectatorSettings in TiltFiveManager's custom inspector,
342  // though they're still accessible from scripts.
343  // Just synchronize spectatorSettings from TiltFiveManager's glassesSettings as needed.
346 
347  // Make sure that the spectated player isn't set to a player index higher than what TiltFiveManager supports
348  var highestSupportedPlayer = (PlayerIndex)GetSupportedPlayerCount();
349  if (spectatorSettings.spectatedPlayer > highestSupportedPlayer)
350  {
351  Log.Warn($"Invalid spectatorSettings.spectatedPlayer [{spectatorSettings.spectatedPlayer}]. TiltFiveManager only supports one player.");
352  spectatorSettings.spectatedPlayer = highestSupportedPlayer;
353  }
354  }

References TiltFive.GlassesSettings.cameraTemplate, TiltFive.TiltFiveManager.GetSupportedPlayerCount(), TiltFive.GlassesSettings.glassesMirrorMode, TiltFive.SpectatorSettings.glassesMirrorMode, TiltFive.TiltFiveManager.glassesSettings, TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager.spectatorSettings, and TiltFive.Logging.Log.Warn().

Referenced by TiltFive.TiltFiveManager.Update().

◆ RunOnStart()

static void TiltFive.TiltFiveManager.RunOnStart ( )
staticprivate

Definition at line 328 of file TiltFiveManager.cs.

329  {
330  Application.quitting += Quit;
331  }

References TiltFive.TiltFiveManager.Quit().

◆ Update()

void TiltFive.TiltFiveManager.Update ( )
private

Update this instance.

Definition at line 164 of file TiltFiveManager.cs.

165  {
166 #if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
168  Player.ScanForNewPlayers();
169  Wand.GetLatestInputs(); // Should only be executed once per frame
170 #endif
173 
174  var spectatedPlayer = spectatorSettings.spectatedPlayer;
175  if (Glasses.TryGetPose(spectatedPlayer, out var spectatedPlayerPose))
176  {
177  spectatorSettings.spectatorCamera?.transform.SetPositionAndRotation(
178  spectatedPlayerPose.position,
179  spectatedPlayerPose.rotation);
180  }
181  }
static bool TryGetPose(PlayerIndex playerIndex, out Pose pose)
Attempts to get the position and orientation of the specified player's glasses.
Definition: Glasses.cs:267
bool NeedsDriverUpdate()
Check if a driver update is needed.

References TiltFive.TiltFiveManager.NeedsDriverUpdate(), TiltFive.TiltFiveManager.playerSettings, TiltFive.TiltFiveManager.RefreshSpectatorSettings(), TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager.spectatorSettings, and TiltFive.Glasses.TryGetPose().

Member Data Documentation

◆ gameBoardSettings

GameBoardSettings TiltFive.TiltFiveManager.gameBoardSettings

◆ glassesSettings

GlassesSettings TiltFive.TiltFiveManager.glassesSettings

◆ logSettings

LogSettings TiltFive.TiltFiveManager.logSettings = new LogSettings()

The log settings.

Definition at line 98 of file TiltFiveManager.cs.

Referenced by TiltFive.TiltFiveManager.Awake().

◆ needsDriverUpdateErroredOnce

bool TiltFive.TiltFiveManager.needsDriverUpdateErroredOnce = false
private

Definition at line 109 of file TiltFiveManager.cs.

Referenced by TiltFive.TiltFiveManager.NeedsDriverUpdate().

◆ needsDriverUpdateNotifiedOnce

bool TiltFive.TiltFiveManager.needsDriverUpdateNotifiedOnce = false
private

Definition at line 108 of file TiltFiveManager.cs.

Referenced by TiltFive.TiltFiveManager.NeedsDriverUpdate().

◆ playerSettings

PlayerSettings TiltFive.TiltFiveManager.playerSettings = new PlayerSettings()
private

◆ primaryWandSettings

WandSettings TiltFive.TiltFiveManager.primaryWandSettings

Definition at line 66 of file TiltFiveManager.cs.

◆ scaleSettings

ScaleSettings TiltFive.TiltFiveManager.scaleSettings

◆ secondaryWandSettings

WandSettings TiltFive.TiltFiveManager.secondaryWandSettings

Definition at line 68 of file TiltFiveManager.cs.

◆ spectatorSettings

SpectatorSettings TiltFive.TiltFiveManager.spectatorSettings = new SpectatorSettings()

Property Documentation

◆ leftWandSettings

WandSettings TiltFive.TiltFiveManager.leftWandSettings
getset

The wand runtime configuration data for the left hand wand.

Definition at line 73 of file TiltFiveManager.cs.

73  {
74  #pragma warning disable 618 // this is for compatibility; disable obsolete warning
75  get => secondaryWandSettings;
76  set => secondaryWandSettings = value;
77  #pragma warning restore 618
78  }
WandSettings secondaryWandSettings

Referenced by TiltFive.TiltFiveManager.GetLatestPoseData(), and TiltFive.TiltFiveManager.RefreshPlayerSettings().

◆ rightWandSettings

WandSettings TiltFive.TiltFiveManager.rightWandSettings
getset

The wand runtime configuration data for the right hand wand.

Definition at line 83 of file TiltFiveManager.cs.

83  {
84  #pragma warning disable 618 // this is for compatibility; disable obsolete warning
85  get => primaryWandSettings;
86  set => primaryWandSettings = value;
87  #pragma warning restore 618
88  }
WandSettings primaryWandSettings

Referenced by TiltFive.TiltFiveManager.GetLatestPoseData(), and TiltFive.TiltFiveManager.RefreshPlayerSettings().


The documentation for this class was generated from the following file: