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 | Static Private Attributes | List of all members
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...
 
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...
 
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 44 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 138 of file TiltFiveManager2.cs.

139  {
140  base.Awake();
141 
142  // Apply log settings
145 
147  {
148  Log.Warn("Failed to send application info to the T5 Control Panel.");
149  enabled = false;
150  }
151 
152  // Initialize the player settings if necessary
153  for (int i = 0; i < allPlayerSettings.Length; i++)
154  {
155  var currentPlayerSettings = allPlayerSettings[i];
156  if(currentPlayerSettings == null)
157  {
158  allPlayerSettings[i] = new PlayerSettings() { PlayerIndex = (PlayerIndex) i + 1 };
159  }
160  }
161  }
static bool SetApplicationInfo()
Definition: Display.cs:144
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
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

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

◆ GetEyeCamera()

Camera TiltFive.TiltFiveManager2.GetEyeCamera ( )

Implements TiltFive.ISceneInfo.

Definition at line 547 of file TiltFiveManager2.cs.

548  {
549  return Glasses.GetLeftEye(PlayerIndex.One);
550  }
The Glasses API and runtime.
Definition: Glasses.cs:35
static Camera GetLeftEye(PlayerIndex playerIndex)
Definition: Glasses.cs:287

References TiltFive.Glasses.GetLeftEye().

◆ GetGameboardPose()

Pose TiltFive.TiltFiveManager2.GetGameboardPose ( )

Implements TiltFive.ISceneInfo.

Definition at line 542 of file TiltFiveManager2.cs.

543  {
545  }
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 552 of file TiltFiveManager2.cs.

553  {
554  return supportedPlayerCount;
555  }

References TiltFive.TiltFiveManager2.supportedPlayerCount.

◆ IsActiveAndEnabled()

bool TiltFive.TiltFiveManager2.IsActiveAndEnabled ( )

Implements TiltFive.ISceneInfo.

Definition at line 557 of file TiltFiveManager2.cs.

558  {
559  return isActiveAndEnabled;
560  }

◆ LateUpdate()

void TiltFive.TiltFiveManager2.LateUpdate ( )
private

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

Definition at line 222 of file TiltFiveManager2.cs.

223  {
224  // Trackables should be updated just before rendering occurs,
225  // after all Update() calls are completed.
226  // This allows any Game Board movements to be finished before we base the
227  // Glasses/Wand poses off of its pose, preventing perceived jittering.
228  for (int i = 0; i < supportedPlayerCount; i++)
229  {
230  var playerSettings = allPlayerSettings[i];
231  if (playerSettings != null)
232  {
233  Player.Update(playerSettings, spectatorSettings);
234  }
235  }
236  }
Provides access to player settings and functionality.
Definition: Player.cs:16
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 249 of file TiltFiveManager2.cs.

250  {
252  {
253  try
254  {
256  bool needsUpdate = compatibility == ServiceCompatibility.Incompatible;
257 
258  if (needsUpdate)
259  {
261  {
262  Log.Warn("Incompatible Tilt Five service. Please update driver package.");
264  }
265  }
266  else
267  {
268  // Not incompatible. Reset the incompatibility warning.
270  }
271  return needsUpdate;
272  }
273  catch (System.DllNotFoundException e)
274  {
275  Log.Info(
276  "Could not connect to Tilt Five plugin for compatibility check: {0}",
277  e.Message);
279  }
280  catch (System.Exception e)
281  {
282  Log.Error(e.Message);
284  }
285  }
286 
287  // Failed to communicate with Tilt Five plugin at some point, so don't know whether
288  // an update is needed or not. Just say no.
289  return false;
290  }
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.TiltFiveManager2.needsDriverUpdateErroredOnce, TiltFive.TiltFiveManager2.needsDriverUpdateNotifiedOnce, and TiltFive.Logging.Log.Warn().

Referenced by TiltFive.TiltFiveManager2.Update().

◆ OnApplicationQuit()

void TiltFive.TiltFiveManager2.OnApplicationQuit ( )
private

Definition at line 353 of file TiltFiveManager2.cs.

354  {
355  OnDisable();
356  }

References TiltFive.TiltFiveManager2.OnDisable().

◆ OnDestroy()

void TiltFive.TiltFiveManager2.OnDestroy ( )
private

Definition at line 348 of file TiltFiveManager2.cs.

349  {
350  Player.OnDisable();
351  }

◆ OnDisable()

void TiltFive.TiltFiveManager2.OnDisable ( )
private

Definition at line 339 of file TiltFiveManager2.cs.

340  {
341 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
342  InputSystem.onBeforeUpdate -= OnBeforeUpdate;
343  //Input.OnDisable();
344 #endif
345  Player.OnDisable();
346  }

Referenced by TiltFive.TiltFiveManager2.OnApplicationQuit().

◆ OnEnable()

void TiltFive.TiltFiveManager2.OnEnable ( )
private

Called when the GameObject is enabled.

Definition at line 295 of file TiltFiveManager2.cs.

296  {
297  try
298  {
299  // TODO: change this to something in the settings drawer once that exists
300  NativePlugin.SetMaxDesiredGlasses((byte)GlassesSettings.MAX_SUPPORTED_GLASSES_COUNT);
301  }
302  catch (System.DllNotFoundException e)
303  {
304  Log.Info(
305  "Could not connect to Tilt Five plugin for setting max glasses: {0}",
306  e.Message);
307  }
308  catch (System.Exception e)
309  {
310  Log.Error(e.Message);
311  }
312 
313  // Initialize the player settings if necessary
314  for (int i = 0; i < allPlayerSettings.Length; i++)
315  {
316  var currentPlayerSettings = allPlayerSettings[i];
317  if (currentPlayerSettings == null)
318  {
320  }
321  }
322 
323  Player.OnEnable(supportedPlayerCount);
324 
325  for (int i = 0; i < supportedPlayerCount; i++)
326  {
327  var playerSettings = allPlayerSettings[i];
328  if (playerSettings != null)
329  {
330  Player.Reset(playerSettings, spectatorSettings);
331  }
332  }
333 
334 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
335  InputSystem.onBeforeUpdate += OnBeforeUpdate;
336 #endif
337  }
GlassesSettings encapsulates all configuration data used by the Glasses' tracking runtime to compute ...
static void SetMaxDesiredGlasses(byte maxCount)

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

◆ Quit()

static void TiltFive.TiltFiveManager2.Quit ( )
staticprivate

Definition at line 363 of file TiltFiveManager2.cs.

364  {
365  try
366  {
368  }
369  catch (System.DllNotFoundException)
370  {
371  // nothing to report on quit if the plugin isn't present
372  }
373  catch (System.Exception e)
374  {
375  Log.Error(e.Message);
376  }
377  }
static void UnloadWorkaround()

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

Referenced by TiltFive.TiltFiveManager2.RunOnStart().

◆ RefreshSpectatorSettings()

void TiltFive.TiltFiveManager2.RefreshSpectatorSettings ( )
private

Definition at line 385 of file TiltFiveManager2.cs.

386  {
387  // Warn developers if they've left the spectatorCamera field empty
388  // TiltFiveManager2's custom inspector should already warn them in the editor, but this warns them again at runtime.
390  {
391  Log.Warn("No spectator camera detected in TiltFiveManager2's spectator settings. A spectator camera is required.");
392  }
393 
394  // Make sure that the spectated player isn't set to a player index higher than what TiltFiveManager2 supports
395  var highestSupportedPlayer = (PlayerIndex)supportedPlayerCount;
396  if (spectatorSettings.spectatedPlayer > highestSupportedPlayer)
397  {
398  Log.Warn($"Invalid spectatorSettings.spectatedPlayer [{spectatorSettings.spectatedPlayer}]. TiltFiveManager2 currently only supports up to Player {highestSupportedPlayer}.");
399  spectatorSettings.spectatedPlayer = highestSupportedPlayer;
400  }
401  }
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 380 of file TiltFiveManager2.cs.

381  {
382  Application.quitting += Quit;
383  }

References TiltFive.TiltFiveManager2.Quit().

◆ Update()

void TiltFive.TiltFiveManager2.Update ( )
private

Update this instance.

Definition at line 191 of file TiltFiveManager2.cs.

192  {
193 #if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
195  Player.ScanForNewPlayers(); // Should only be executed once per frame
196  Wand.GetLatestInputs(); // Should only be executed once per frame
197 #endif
199 
200  for (int i = 0; i < supportedPlayerCount; i++)
201  {
202  var playerSettings = allPlayerSettings[i];
203  if(playerSettings != null)
204  {
205  Player.Update(playerSettings, spectatorSettings);
206  }
207  }
208 
209  var spectatedPlayer = spectatorSettings.spectatedPlayer;
210  if (Glasses.TryGetPose(spectatedPlayer, out var spectatedPlayerPose))
211  {
212  spectatorSettings.spectatorCamera?.transform.SetPositionAndRotation(
213  spectatedPlayerPose.position,
214  spectatedPlayerPose.rotation);
215  }
216  }
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.
The Wand API and runtime.
Definition: Wand.cs:55

References TiltFive.TiltFiveManager2.allPlayerSettings, TiltFive.TiltFiveManager2.NeedsDriverUpdate(), TiltFive.TiltFiveManager2.RefreshSpectatorSettings(), TiltFive.SpectatorSettings.spectatedPlayer, TiltFive.SpectatorSettings.spectatorCamera, TiltFive.TiltFiveManager2.spectatorSettings, TiltFive.TiltFiveManager2.supportedPlayerCount, and TiltFive.Glasses.TryGetPose().

Member Data Documentation

◆ allPlayerSettings

PlayerSettings [] TiltFive.TiltFiveManager2.allPlayerSettings = new PlayerSettings[PlayerSettings.MAX_SUPPORTED_PLAYERS]

◆ logSettings

LogSettings TiltFive.TiltFiveManager2.logSettings = new LogSettings()

The log settings.

Definition at line 118 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.Awake().

◆ needsDriverUpdateErroredOnce

bool TiltFive.TiltFiveManager2.needsDriverUpdateErroredOnce = false
private

Definition at line 131 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.NeedsDriverUpdate().

◆ needsDriverUpdateNotifiedOnce

bool TiltFive.TiltFiveManager2.needsDriverUpdateNotifiedOnce = false
private

Definition at line 130 of file TiltFiveManager2.cs.

Referenced by TiltFive.TiltFiveManager2.NeedsDriverUpdate().

◆ spectatorSettings

SpectatorSettings TiltFive.TiltFiveManager2.spectatorSettings = new SpectatorSettings()

◆ supportedPlayerCount

uint TiltFive.TiltFiveManager2.supportedPlayerCount = 3

◆ upgradeInProgress

bool TiltFive.TiltFiveManager2.upgradeInProgress = false
staticprivate

Definition at line 133 of file TiltFiveManager2.cs.

Property Documentation

◆ playerFourSettings

PlayerSettings TiltFive.TiltFiveManager2.playerFourSettings
get

The fourth player's runtime configuration data.

Definition at line 94 of file TiltFiveManager2.cs.

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

◆ playerOneSettings

PlayerSettings TiltFive.TiltFiveManager2.playerOneSettings
get

The first player's runtime configuration data.

Definition at line 49 of file TiltFiveManager2.cs.

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

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

◆ playerThreeSettings

PlayerSettings TiltFive.TiltFiveManager2.playerThreeSettings
get

The third player's runtime configuration data.

Definition at line 79 of file TiltFiveManager2.cs.

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

◆ playerTwoSettings

PlayerSettings TiltFive.TiltFiveManager2.playerTwoSettings
get

The second player's runtime configuration data.

Definition at line 64 of file TiltFiveManager2.cs.

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

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