Tilt Five™ Unity API  1.4.1
TiltFive.TiltFiveManager2 Class Reference

The Tilt Five manager. More...

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

Public Member Functions

bool NeedsDriverUpdate ()
 Check if a driver update is needed. More...
 
bool TryGetPlayerSettings (PlayerIndex playerIndex, out PlayerSettings playerSettings)
 Gets the player settings for the specified player. More...
 
float GetScaleToUWRLD_UGBD ()
 
Pose GetGameboardPose ()
 
Camera GetEyeCamera ()
 
uint GetSupportedPlayerCount ()
 
bool IsActiveAndEnabled ()
 

Public Attributes

PlayerSettings[] allPlayerSettings = new PlayerSettings[PlayerSettings.MAX_SUPPORTED_PLAYERS]
 
uint supportedPlayerCount = 3
 
SpectatorSettings spectatorSettings = new SpectatorSettings()
 The spectator camera's runtime configuration data. More...
 
GraphicsSettings graphicsSettings = new GraphicsSettings()
 Project-wide graphics settings related to Tilt Five. More...
 
LogSettings logSettings = new LogSettings()
 The log settings. More...
 

Protected Member Functions

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

Properties

PlayerSettings playerOneSettings [get]
 The first player's runtime configuration data. More...
 
PlayerSettings playerTwoSettings [get]
 The second player's runtime configuration data. More...
 
PlayerSettings playerThreeSettings [get]
 The third player's runtime configuration data. More...
 
PlayerSettings playerFourSettings [get]
 The fourth player's runtime configuration data. More...
 
- Properties inherited from TiltFive.SingletonComponent< TiltFiveManager2 >
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 OnEnable ()
 Called when the GameObject is enabled. More...
 
void OnDisable ()
 
void OnDestroy ()
 
void OnApplicationQuit ()
 
void RefreshSpectatorSettings ()
 

Static Private Member Functions

static void Quit ()
 
static void RunOnStart ()
 

Private Attributes

bool needsDriverUpdateNotifiedOnce = false
 
bool needsDriverUpdateErroredOnce = false
 

Static Private Attributes

static bool upgradeInProgress = false
 

Detailed Description

The Tilt Five manager.

Definition at line 45 of file TiltFiveManager2.cs.

Member Function Documentation

◆ Awake()

override void TiltFive.TiltFiveManager2.Awake ( )
protectedvirtual

Awake this instance.

Reimplemented from TiltFive.SingletonComponent< TiltFiveManager2 >.

Definition at line 153 of file TiltFiveManager2.cs.

154  {
155  base.Awake();
156 
157  // Apply log settings
160 
161  // Store graphics settings
162  graphicsSettings.applicationTargetFramerate = Application.targetFrameRate;
163  graphicsSettings.applicationVSyncCount = QualitySettings.vSyncCount;
164 
165  if (!SystemControl.SetPlatformContext())
166  {
167  Log.Warn("Failed to set application context.");
168  enabled = false;
169  }
170 
171  if (!SystemControl.SetApplicationInfo())
172  {
173  Log.Warn("Failed to send application info to the T5 Service.");
174  enabled = false;
175  }
176 
177  // Initialize the player settings if necessary
178  for (int i = 0; i < allPlayerSettings.Length; i++)
179  {
180  var currentPlayerSettings = allPlayerSettings[i];
181  if(currentPlayerSettings == null)
182  {
183  allPlayerSettings[i] = new PlayerSettings() { PlayerIndex = (PlayerIndex) i + 1 };
184  }
185  }
186  }
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
LogSettings logSettings
The log settings.
PlayerSettings[] allPlayerSettings
GraphicsSettings graphicsSettings
Project-wide graphics settings related to Tilt Five.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

References TiltFive.TiltFiveManager2.allPlayerSettings, TiltFive.TiltFiveManager2.graphicsSettings, TiltFive.Logging.LogSettings.level, TiltFive.Logging.Log.LogLevel, TiltFive.TiltFiveManager2.logSettings, TiltFive.Logging.LogSettings.TAG, TiltFive.Logging.Log.TAG, and TiltFive.Logging.Log.Warn().

◆ GetEyeCamera()

Camera TiltFive.TiltFiveManager2.GetEyeCamera ( )

Implements TiltFive.ISceneInfo.

Definition at line 685 of file TiltFiveManager2.cs.

686  {
687  return Glasses.GetLeftEye(PlayerIndex.One);
688  }
The Glasses API and runtime.
Definition: Glasses.cs:35
static Camera GetLeftEye(PlayerIndex playerIndex)
Gets the left eye camera for the specified player's glasses.
Definition: Glasses.cs:268

References TiltFive.Glasses.GetLeftEye().

◆ GetGameboardPose()

Pose TiltFive.TiltFiveManager2.GetGameboardPose ( )

Implements TiltFive.ISceneInfo.

Definition at line 680 of file TiltFiveManager2.cs.

681  {
683  }
Vector3 gameBoardRotation
The game board rotation or focal rotational offset.
Vector3 gameBoardCenter
The game board position or focal position offset.
GameBoardSettings gameboardSettings
PlayerSettings playerOneSettings
The first player's runtime configuration data.

References TiltFive.GameBoardSettings.gameBoardCenter, TiltFive.GameBoardSettings.gameBoardRotation, TiltFive.PlayerSettings.gameboardSettings, and TiltFive.TiltFiveManager2.playerOneSettings.

◆ GetScaleToUWRLD_UGBD()

float TiltFive.TiltFiveManager2.GetScaleToUWRLD_UGBD ( )

◆ GetSupportedPlayerCount()

uint TiltFive.TiltFiveManager2.GetSupportedPlayerCount ( )

Implements TiltFive.ISceneInfo.

Definition at line 690 of file TiltFiveManager2.cs.

691  {
692  return supportedPlayerCount;
693  }

References TiltFive.TiltFiveManager2.supportedPlayerCount.

◆ IsActiveAndEnabled()

bool TiltFive.TiltFiveManager2.IsActiveAndEnabled ( )

Implements TiltFive.ISceneInfo.

Definition at line 695 of file TiltFiveManager2.cs.

696  {
697  return isActiveAndEnabled;
698  }

◆ LateUpdate()

void TiltFive.TiltFiveManager2.LateUpdate ( )
private

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

Definition at line 281 of file TiltFiveManager2.cs.

282  {
283  // Trackables should be updated just before rendering occurs,
284  // after all Update() calls are completed.
285  // This allows any Game Board movements to be finished before we base the
286  // Glasses/Wand poses off of its pose, preventing perceived jittering.
287  for (int i = 0; i < supportedPlayerCount; i++)
288  {
289  var playerSettings = allPlayerSettings[i];
290  if (playerSettings != null)
291  {
292  Player.Update(playerSettings, spectatorSettings);
293  }
294  }
295  }
Provides access to player settings and functionality.
Definition: Player.cs:31
SpectatorSettings spectatorSettings
The spectator camera's runtime configuration data.

References TiltFive.TiltFiveManager2.allPlayerSettings, TiltFive.TiltFiveManager2.spectatorSettings, and TiltFive.TiltFiveManager2.supportedPlayerCount.

◆ NeedsDriverUpdate()

bool TiltFive.TiltFiveManager2.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 308 of file TiltFiveManager2.cs.

309  {
311  {
312  try
313  {
314  ServiceCompatibility compatibility = SystemControl.GetServiceCompatibility();
315  bool needsUpdate = compatibility == ServiceCompatibility.Incompatible;
316 
317  if (needsUpdate)
318  {
320  {
321  Log.Warn("Incompatible Tilt Five service. Please update driver package.");
323  }
324  }
325  else
326  {
327  // Not incompatible. Reset the incompatibility warning.
329  }
330  return needsUpdate;
331  }
332  catch (System.DllNotFoundException e)
333  {
334  Log.Info(
335  "Could not connect to Tilt Five plugin for compatibility check: {0}",
336  e.Message);
338  }
339  catch (System.Exception e)
340  {
341  Log.Error(e.Message);
343  }
344  }
345 
346  // Failed to communicate with Tilt Five plugin at some point, so don't know whether
347  // an update is needed or not. Just say no.
348  return false;
349  }
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
ServiceCompatibility
Whether the running service is compatible.

References TiltFive.Logging.Log.Error(), TiltFive.Logging.Log.Info(), TiltFive.TiltFiveManager2.needsDriverUpdateErroredOnce, TiltFive.TiltFiveManager2.needsDriverUpdateNotifiedOnce, and TiltFive.Logging.Log.Warn().

Referenced by TiltFive.TiltFiveManager2.Update().

◆ OnApplicationQuit()

void TiltFive.TiltFiveManager2.OnApplicationQuit ( )
private

Definition at line 494 of file TiltFiveManager2.cs.

495  {
496  OnDisable();
497  }

References TiltFive.TiltFiveManager2.OnDisable().

◆ OnDestroy()

void TiltFive.TiltFiveManager2.OnDestroy ( )
private

Definition at line 489 of file TiltFiveManager2.cs.

490  {
491  Player.OnDisable();
492  }

◆ OnDisable()

void TiltFive.TiltFiveManager2.OnDisable ( )
private

Definition at line 480 of file TiltFiveManager2.cs.

481  {
482 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
483  InputSystem.onBeforeUpdate -= OnBeforeUpdate;
484  //Input.OnDisable();
485 #endif
486  Player.OnDisable();
487  }

Referenced by TiltFive.TiltFiveManager2.OnApplicationQuit().

◆ OnEnable()

void TiltFive.TiltFiveManager2.OnEnable ( )
private

Called when the GameObject is enabled.

Definition at line 438 of file TiltFiveManager2.cs.

439  {
440  try
441  {
442  // TODO: change this to something in the settings drawer once that exists
443  NativePlugin.SetMaxDesiredGlasses((byte)GlassesSettings.MAX_SUPPORTED_GLASSES_COUNT);
444  }
445  catch (System.DllNotFoundException e)
446  {
447  Log.Info(
448  "Could not connect to Tilt Five plugin for setting max glasses: {0}",
449  e.Message);
450  }
451  catch (System.Exception e)
452  {
453  Log.Error(e.Message);
454  }
455 
456  // Initialize the player settings if necessary
457  for (int i = 0; i < allPlayerSettings.Length; i++)
458  {
459  var currentPlayerSettings = allPlayerSettings[i];
460  if (currentPlayerSettings == null)
461  {
463  }
464  }
465 
466  for (int i = 0; i < supportedPlayerCount; i++)
467  {
468  var playerSettings = allPlayerSettings[i];
469  if (playerSettings != null)
470  {
471  Player.Reset(playerSettings, spectatorSettings);
472  }
473  }
474 
475 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
476  InputSystem.onBeforeUpdate += OnBeforeUpdate;
477 #endif
478  }
GlassesSettings encapsulates all configuration data used by the Glasses' tracking runtime to compute ...

References TiltFive.TiltFiveManager2.allPlayerSettings, TiltFive.Logging.Log.Error(), TiltFive.Logging.Log.Info(), TiltFive.TiltFiveManager2.spectatorSettings, and TiltFive.TiltFiveManager2.supportedPlayerCount.

◆ Quit()

static void TiltFive.TiltFiveManager2.Quit ( )
staticprivate

Definition at line 504 of file TiltFiveManager2.cs.

505  {
506  try
507  {
508  NativePlugin.UnloadWorkaround();
509  }
510  catch (System.DllNotFoundException)
511  {
512  // nothing to report on quit if the plugin isn't present
513  }
514  catch (System.Exception e)
515  {
516  Log.Error(e.Message);
517  }
518  }

References TiltFive.Logging.Log.Error().

Referenced by TiltFive.TiltFiveManager2.RunOnStart().

◆ RefreshSpectatorSettings()

void TiltFive.TiltFiveManager2.RefreshSpectatorSettings ( )
private

Definition at line 526 of file TiltFiveManager2.cs.

527  {
528  // Warn developers if they've left the spectatorCamera field empty
529  // TiltFiveManager2's custom inspector should already warn them in the editor, but this warns them again at runtime.
531  {
532  Log.Warn("No spectator camera detected in TiltFiveManager2's spectator settings. A spectator camera is required.");
533  }
534 
535  // Make sure that the spectated player isn't set to a player index higher than what TiltFiveManager2 supports
536  var highestSupportedPlayer = (PlayerIndex)supportedPlayerCount;
537  if (spectatorSettings.spectatedPlayer > highestSupportedPlayer)
538  {
539  Log.Warn($"Invalid spectatorSettings.spectatedPlayer [{spectatorSettings.spectatedPlayer}]. TiltFiveManager2 currently only supports up to Player {highestSupportedPlayer}.");
540  spectatorSettings.spectatedPlayer = highestSupportedPlayer;
541  }
542  }
PlayerIndex spectatedPlayer
The player that will have their perspective mirrored on screen.
Camera spectatorCamera
The camera used for rendering the onscreen preview

References TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager2.spectatorSettings, TiltFive.TiltFiveManager2.supportedPlayerCount, and TiltFive.Logging.Log.Warn().

Referenced by TiltFive.TiltFiveManager2.Update().

◆ RunOnStart()

static void TiltFive.TiltFiveManager2.RunOnStart ( )
staticprivate

Definition at line 521 of file TiltFiveManager2.cs.

522  {
523  Application.quitting += Quit;
524  }

References TiltFive.TiltFiveManager2.Quit().

◆ TryGetPlayerSettings()

bool TiltFive.TiltFiveManager2.TryGetPlayerSettings ( PlayerIndex  playerIndex,
out PlayerSettings  playerSettings 
)

Gets the player settings for the specified player.

Parameters
playerIndex
playerSettings
Returns
Returns false and sets playerSettings to null if an invalid player index is provided.

Definition at line 357 of file TiltFiveManager2.cs.

358  {
359  switch (playerIndex)
360  {
361  case PlayerIndex.One:
362  playerSettings = playerOneSettings;
363  return true;
364  case PlayerIndex.Two:
365  playerSettings = playerTwoSettings;
366  return true;
367  case PlayerIndex.Three:
368  playerSettings = playerThreeSettings;
369  return true;
370  case PlayerIndex.Four:
371  playerSettings = playerFourSettings;
372  return true;
373  default:
374  playerSettings = null;
375  return false;
376  }
377  }
PlayerSettings playerFourSettings
The fourth player's runtime configuration data.
PlayerSettings playerTwoSettings
The second player's runtime configuration data.
PlayerSettings playerThreeSettings
The third player's runtime configuration data.

References TiltFive.TiltFiveManager2.playerFourSettings, TiltFive.TiltFiveManager2.playerOneSettings, TiltFive.TiltFiveManager2.playerThreeSettings, and TiltFive.TiltFiveManager2.playerTwoSettings.

Referenced by TiltFive.Player.TryGetSettings().

◆ Update()

void TiltFive.TiltFiveManager2.Update ( )
private

Update this instance.

Definition at line 223 of file TiltFiveManager2.cs.

224  {
225 #if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
227  Player.ScanForNewPlayers(); // Should only be executed once per frame
228  Wand.GetLatestInputs(); // Should only be executed once per frame
229 #endif
231  Display.ApplyGraphicsSettings(graphicsSettings);
232 
233  for (int i = 0; i < supportedPlayerCount; i++)
234  {
235  var playerSettings = allPlayerSettings[i];
236  if (playerSettings != null)
237  {
238  Player.Update(playerSettings, spectatorSettings);
239  }
240  }
241 
242  var spectatedPlayer = spectatorSettings.spectatedPlayer;
243  if (Glasses.TryGetPreviewPose(spectatedPlayer, out var spectatedPlayerPose))
244  {
245  spectatorSettings.spectatorCamera?.transform.SetPositionAndRotation(
246  spectatedPlayerPose.position,
247  spectatedPlayerPose.rotation);
248  }
249 
250 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
251  var devices = InputUser.GetUnpairedInputDevices();
252  if (devices.Count > 0)
253  {
254  foreach (InputDevice dev in devices)
255  {
256  if (dev is WandDevice)
257  {
258  var headPoseRoot = Glasses.GetPoseRoot(((WandDevice)dev).playerIndex);
259 
260  if (headPoseRoot != null)
261  {
262  var playerInput = headPoseRoot.GetComponentInChildren<PlayerInput>();
263 
264  if (playerInput != null && playerInput.user.valid)
265  {
266  Log.Warn($"Unpaired Wand Device [{((WandDevice)dev).ControllerIndex}] found and paired to Player [{((WandDevice)dev).playerIndex}].");
267  InputUser.PerformPairingWithDevice(dev, playerInput.user);
268  playerInput.user.ActivateControlScheme("XR");
269  }
270  }
271  }
272  }
273  }
274 #endif
275  }
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:233
static GameObject GetPoseRoot(PlayerIndex playerIndex)
Gets the pose root GameObject for the specified player.
Definition: Glasses.cs:254
bool NeedsDriverUpdate()
Check if a driver update is needed.
The Wand API and runtime.
Definition: Wand.cs:56

References TiltFive.TiltFiveManager2.allPlayerSettings, TiltFive.Glasses.GetPoseRoot(), TiltFive.TiltFiveManager2.graphicsSettings, TiltFive.TiltFiveManager2.NeedsDriverUpdate(), TiltFive.TiltFiveManager2.RefreshSpectatorSettings(), TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager2.spectatorSettings, TiltFive.TiltFiveManager2.supportedPlayerCount, TiltFive.Glasses.TryGetPreviewPose(), and TiltFive.Logging.Log.Warn().

Member Data Documentation

◆ allPlayerSettings

◆ graphicsSettings

GraphicsSettings TiltFive.TiltFiveManager2.graphicsSettings = new GraphicsSettings()

Project-wide graphics settings related to Tilt Five.

Definition at line 119 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.Awake(), and TiltFive.TiltFiveManager2.Update().

◆ logSettings

LogSettings TiltFive.TiltFiveManager2.logSettings = new LogSettings()

The log settings.

Definition at line 124 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.Awake().

◆ needsDriverUpdateErroredOnce

bool TiltFive.TiltFiveManager2.needsDriverUpdateErroredOnce = false
private

Definition at line 137 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.NeedsDriverUpdate().

◆ needsDriverUpdateNotifiedOnce

bool TiltFive.TiltFiveManager2.needsDriverUpdateNotifiedOnce = false
private

Definition at line 136 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.NeedsDriverUpdate().

◆ spectatorSettings

SpectatorSettings TiltFive.TiltFiveManager2.spectatorSettings = new SpectatorSettings()

◆ supportedPlayerCount

◆ upgradeInProgress

bool TiltFive.TiltFiveManager2.upgradeInProgress = false
staticprivate

Definition at line 139 of file TiltFiveManager2.cs.

Property Documentation

◆ playerFourSettings

PlayerSettings TiltFive.TiltFiveManager2.playerFourSettings
get

The fourth player's runtime configuration data.

Definition at line 95 of file TiltFiveManager2.cs.

96  {
97  get
98  {
99  if (allPlayerSettings[3] == null)
100  {
102  }
103  return allPlayerSettings[3];
104  }
105  }

Referenced by TiltFive.TiltFiveManager2.TryGetPlayerSettings().

◆ playerOneSettings

PlayerSettings TiltFive.TiltFiveManager2.playerOneSettings
get

The first player's runtime configuration data.

Definition at line 50 of file TiltFiveManager2.cs.

51  {
52  get
53  {
54  if(allPlayerSettings[0] == null)
55  {
57  }
58  return allPlayerSettings[0];
59  }
60  }

Referenced by TiltFive.TiltFiveManager2.GetGameboardPose(), TiltFive.TiltFiveManager2.GetScaleToUWRLD_UGBD(), and TiltFive.TiltFiveManager2.TryGetPlayerSettings().

◆ playerThreeSettings

PlayerSettings TiltFive.TiltFiveManager2.playerThreeSettings
get

The third player's runtime configuration data.

Definition at line 80 of file TiltFiveManager2.cs.

81  {
82  get
83  {
84  if (allPlayerSettings[2] == null)
85  {
87  }
88  return allPlayerSettings[2];
89  }
90  }

Referenced by TiltFive.TiltFiveManager2.TryGetPlayerSettings().

◆ playerTwoSettings

PlayerSettings TiltFive.TiltFiveManager2.playerTwoSettings
get

The second player's runtime configuration data.

Definition at line 65 of file TiltFiveManager2.cs.

66  {
67  get
68  {
69  if (allPlayerSettings[1] == null)
70  {
72  }
73  return allPlayerSettings[1];
74  }
75  }

Referenced by TiltFive.TiltFiveManager2.TryGetPlayerSettings().


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