Tilt Five™ Unity API  1.3.0
 
Loading...
Searching...
No Matches
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.
 
float GetScaleToUWRLD_UGBD ()
 
Pose GetGameboardPose ()
 
Camera GetEyeCamera ()
 
uint GetSupportedPlayerCount ()
 
bool IsActiveAndEnabled ()
 
float GetScaleToUWRLD_UGBD ()
 
Pose GetGameboardPose ()
 
Camera GetEyeCamera ()
 
uint GetSupportedPlayerCount ()
 
bool IsActiveAndEnabled ()
 

Public Attributes

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

Protected Member Functions

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

Properties

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

Private Member Functions

void Update ()
 Update this instance.
 
void LateUpdate ()
 Update this instance after all components have finished executing their Update() functions.
 
void GetLatestPoseData ()
 Obtains the latest pose for all trackable objects.
 
void OnEnable ()
 Called when the GameObject is enabled.
 
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
122 Log.LogLevel = logSettings.level;
123 Log.TAG = logSettings.TAG;
124
126 {
127 Log.Warn("Failed to send application info to the T5 Control Panel.");
128 enabled = false;
129 }
130
132
133 spectatorSettings.spectatorCamera = glassesSettings.cameraTemplate;
134 spectatorSettings.glassesMirrorMode = glassesSettings.glassesMirrorMode;
135 spectatorSettings.spectatedPlayer = playerSettings.PlayerIndex;
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
LogSettings logSettings
The log settings.
PlayerSettings playerSettings
GlassesSettings glassesSettings
The glasses runtime configuration data.

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

◆ GetEyeCamera()

Camera TiltFive.TiltFiveManager.GetEyeCamera ( )

Implements TiltFive.ISceneInfo.

Definition at line 470 of file TiltFiveManager.cs.

471 {
472 return Glasses.GetLeftEye(PlayerIndex.One);
473 }
The Glasses API and runtime.
Definition: Glasses.cs:35
static Camera GetLeftEye(PlayerIndex playerIndex)
Definition: Glasses.cs:305
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 465 of file TiltFiveManager.cs.

466 {
467 return new Pose(gameBoardSettings.gameBoardCenter, Quaternion.Euler(gameBoardSettings.gameBoardRotation));
468 }
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 206 of file TiltFiveManager.cs.

207 {
211 }
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:56
static void Update(WandSettings wandSettings, ScaleSettings scaleSettings, GameBoardSettings gameBoardSettings, PlayerIndex playerIndex=PlayerIndex.One)
Definition: Wand.cs:152

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 460 of file TiltFiveManager.cs.

461 {
463 }
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 475 of file TiltFiveManager.cs.

476 {
477 return 1; // TODO: Change this if we decide to include spectators with TiltFiveManager
478 }

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

◆ IsActiveAndEnabled()

bool TiltFive.TiltFiveManager.IsActiveAndEnabled ( )

Implements TiltFive.ISceneInfo.

Definition at line 480 of file TiltFiveManager.cs.

481 {
482 return isActiveAndEnabled;
483 }

◆ LateUpdate()

void TiltFive.TiltFiveManager.LateUpdate ( )
private

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

Definition at line 194 of file TiltFiveManager.cs.

195 {
196 // Trackables should be updated just before rendering occurs,
197 // after all Update() calls are completed.
198 // This allows any Game Board movements to be finished before we base the
199 // Glasses/Wand poses off of its pose, preventing perceived jittering.
201 }
Provides access to player settings and functionality.
Definition: Player.cs:16
SpectatorSettings spectatorSettings
The spectator camera's runtime configuration data.

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 224 of file TiltFiveManager.cs.

225 {
227 {
228 try
229 {
231 bool needsUpdate = compatibility == ServiceCompatibility.Incompatible;
232
233 if (needsUpdate)
234 {
236 {
237 Log.Warn("Incompatible Tilt Five service. Please update driver package.");
239 }
240 }
241 else
242 {
243 // Not incompatible. Reset the incompatibility warning.
245 }
246 return needsUpdate;
247 }
248 catch (System.DllNotFoundException e)
249 {
250 Log.Info(
251 "Could not connect to Tilt Five plugin for compatibility check: {0}",
252 e.Message);
254 }
255 catch (System.Exception e)
256 {
257 Log.Error(e.Message);
259 }
260 }
261
262 // Failed to communicate with Tilt Five plugin at some point, so don't know whether
263 // an update is needed or not. Just say no.
264 return false;
265 }
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 308 of file TiltFiveManager.cs.

309 {
310 OnDisable();
311 }

References TiltFive.TiltFiveManager.OnDisable().

◆ OnDestroy()

void TiltFive.TiltFiveManager.OnDestroy ( )
private

Definition at line 303 of file TiltFiveManager.cs.

304 {
305 Player.OnDisable();
306 }

◆ OnDisable()

void TiltFive.TiltFiveManager.OnDisable ( )
private

Definition at line 295 of file TiltFiveManager.cs.

296 {
297#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
298 InputSystem.onBeforeUpdate -= OnBeforeUpdate;
299#endif
300 Player.OnDisable();
301 }

Referenced by TiltFive.TiltFiveManager.OnApplicationQuit().

◆ OnEnable()

void TiltFive.TiltFiveManager.OnEnable ( )
private

Called when the GameObject is enabled.

Definition at line 270 of file TiltFiveManager.cs.

271 {
272 try
273 {
275 }
276 catch (System.DllNotFoundException e)
277 {
278 Log.Info(
279 "Could not connect to Tilt Five plugin for setting max glasses: {0}",
280 e.Message);
281 }
282 catch (System.Exception e)
283 {
284 Log.Error(e.Message);
285 }
286
289
290#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
291 InputSystem.onBeforeUpdate += OnBeforeUpdate;
292#endif
293 }
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 318 of file TiltFiveManager.cs.

319 {
320 try
321 {
323 }
324 catch (System.DllNotFoundException)
325 {
326 // Nothing to report on quit if the plugin isn't present
327 }
328 catch (System.Exception e)
329 {
330 Log.Error(e.Message);
331 }
332 }
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 363 of file TiltFiveManager.cs.

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

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

Referenced by TiltFive.TiltFiveManager.Awake().

◆ RefreshSpectatorSettings()

void TiltFive.TiltFiveManager.RefreshSpectatorSettings ( )
private

Definition at line 340 of file TiltFiveManager.cs.

341 {
342 // Warn developers if they've left the glassesSettings camera template field empty, since it's still required for the original TiltFiveManager
344 {
345 Log.Warn("No camera template detected in TiltFiveManager's glassesSettings. A camera template is required.");
346 }
347
348 // We don't expose any global settings like SpectatorSettings in TiltFiveManager's custom inspector,
349 // though they're still accessible from scripts.
350 // Just synchronize spectatorSettings from TiltFiveManager's glassesSettings as needed.
351 spectatorSettings.spectatorCamera = glassesSettings.cameraTemplate;
352 spectatorSettings.glassesMirrorMode = glassesSettings.glassesMirrorMode;
353
354 // Make sure that the spectated player isn't set to a player index higher than what TiltFiveManager supports
355 var highestSupportedPlayer = (PlayerIndex)GetSupportedPlayerCount();
356 if (spectatorSettings.spectatedPlayer > highestSupportedPlayer)
357 {
358 Log.Warn($"Invalid spectatorSettings.spectatedPlayer [{spectatorSettings.spectatedPlayer}]. TiltFiveManager only supports one player.");
359 spectatorSettings.spectatedPlayer = highestSupportedPlayer;
360 }
361 }
PlayerIndex spectatedPlayer
The player that will have their perspective mirrored on screen.

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

Referenced by TiltFive.TiltFiveManager.Update().

◆ RunOnStart()

static void TiltFive.TiltFiveManager.RunOnStart ( )
staticprivate

Definition at line 335 of file TiltFiveManager.cs.

336 {
337 Application.quitting += Quit;
338 }

References TiltFive.TiltFiveManager.Quit().

◆ Update()

void TiltFive.TiltFiveManager.Update ( )
private

Update this instance.

Definition at line 171 of file TiltFiveManager.cs.

172 {
173#if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
175 Player.ScanForNewPlayers();
176 Wand.GetLatestInputs(); // Should only be executed once per frame
177#endif
180
181 var spectatedPlayer = spectatorSettings.spectatedPlayer;
182 if (Glasses.TryGetPreviewPose(spectatedPlayer, out var spectatedPlayerPose))
183 {
184 spectatorSettings.spectatorCamera?.transform.SetPositionAndRotation(
185 spectatedPlayerPose.position,
186 spectatedPlayerPose.rotation);
187 }
188 }
static bool TryGetPreviewPose(PlayerIndex playerIndex, out Pose pose)
Attempts to get the position and orientation of the specified player's glasses, smoothed for on-scree...
Definition: Glasses.cs:285
Camera spectatorCamera
The camera used for rendering the onscreen preview.
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.TryGetPreviewPose().

Member Data Documentation

◆ gameBoardSettings

◆ 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

◆ 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()

The spectator camera's runtime configuration data.

Definition at line 93 of file TiltFiveManager.cs.

Referenced by TiltFive.TiltFiveManager.LateUpdate(), TiltFive.TiltFiveManager.RefreshSpectatorSettings(), and TiltFive.TiltFiveManager.Update().

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
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
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: