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

Protected Member Functions

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

Properties

PlayerSettings playerOneSettings [get]
 The first player's runtime configuration data.
 
PlayerSettings playerTwoSettings [get]
 The second player's runtime configuration data.
 
PlayerSettings playerThreeSettings [get]
 The third player's runtime configuration data.
 
PlayerSettings playerFourSettings [get]
 The fourth player's runtime configuration data.
 
- Properties inherited from TiltFive.SingletonComponent< TiltFiveManager2 >
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 OnEnable ()
 Called when the GameObject is enabled.
 
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
143 Log.LogLevel = logSettings.level;
144 Log.TAG = logSettings.TAG;
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 {
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
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.TiltFiveManager2.logSettings, TiltFive.Display.SetApplicationInfo(), TiltFive.Logging.LogSettings.TAG, and TiltFive.Logging.Log.Warn().

◆ GetEyeCamera()

Camera TiltFive.TiltFiveManager2.GetEyeCamera ( )

Implements TiltFive.ISceneInfo.

Definition at line 554 of file TiltFiveManager2.cs.

555 {
556 return Glasses.GetLeftEye(PlayerIndex.One);
557 }
The Glasses API and runtime.
Definition: Glasses.cs:35
static Camera GetLeftEye(PlayerIndex playerIndex)
Definition: Glasses.cs:305

References TiltFive.Glasses.GetLeftEye().

◆ GetGameboardPose()

Pose TiltFive.TiltFiveManager2.GetGameboardPose ( )

Implements TiltFive.ISceneInfo.

Definition at line 549 of file TiltFiveManager2.cs.

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

560 {
562 }

References TiltFive.TiltFiveManager2.supportedPlayerCount.

◆ IsActiveAndEnabled()

bool TiltFive.TiltFiveManager2.IsActiveAndEnabled ( )

Implements TiltFive.ISceneInfo.

Definition at line 564 of file TiltFiveManager2.cs.

565 {
566 return isActiveAndEnabled;
567 }

◆ LateUpdate()

void TiltFive.TiltFiveManager2.LateUpdate ( )
private

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

Definition at line 229 of file TiltFiveManager2.cs.

230 {
231 // Trackables should be updated just before rendering occurs,
232 // after all Update() calls are completed.
233 // This allows any Game Board movements to be finished before we base the
234 // Glasses/Wand poses off of its pose, preventing perceived jittering.
235 for (int i = 0; i < supportedPlayerCount; i++)
236 {
237 var playerSettings = allPlayerSettings[i];
238 if (playerSettings != null)
239 {
240 Player.Update(playerSettings, spectatorSettings);
241 }
242 }
243 }
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 256 of file TiltFiveManager2.cs.

257 {
259 {
260 try
261 {
263 bool needsUpdate = compatibility == ServiceCompatibility.Incompatible;
264
265 if (needsUpdate)
266 {
268 {
269 Log.Warn("Incompatible Tilt Five service. Please update driver package.");
271 }
272 }
273 else
274 {
275 // Not incompatible. Reset the incompatibility warning.
277 }
278 return needsUpdate;
279 }
280 catch (System.DllNotFoundException e)
281 {
282 Log.Info(
283 "Could not connect to Tilt Five plugin for compatibility check: {0}",
284 e.Message);
286 }
287 catch (System.Exception e)
288 {
289 Log.Error(e.Message);
291 }
292 }
293
294 // Failed to communicate with Tilt Five plugin at some point, so don't know whether
295 // an update is needed or not. Just say no.
296 return false;
297 }
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 360 of file TiltFiveManager2.cs.

361 {
362 OnDisable();
363 }

References TiltFive.TiltFiveManager2.OnDisable().

◆ OnDestroy()

void TiltFive.TiltFiveManager2.OnDestroy ( )
private

Definition at line 355 of file TiltFiveManager2.cs.

356 {
357 Player.OnDisable();
358 }

◆ OnDisable()

void TiltFive.TiltFiveManager2.OnDisable ( )
private

Definition at line 346 of file TiltFiveManager2.cs.

347 {
348#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
349 InputSystem.onBeforeUpdate -= OnBeforeUpdate;
350 //Input.OnDisable();
351#endif
352 Player.OnDisable();
353 }

Referenced by TiltFive.TiltFiveManager2.OnApplicationQuit().

◆ OnEnable()

void TiltFive.TiltFiveManager2.OnEnable ( )
private

Called when the GameObject is enabled.

Definition at line 302 of file TiltFiveManager2.cs.

303 {
304 try
305 {
306 // TODO: change this to something in the settings drawer once that exists
307 NativePlugin.SetMaxDesiredGlasses((byte)GlassesSettings.MAX_SUPPORTED_GLASSES_COUNT);
308 }
309 catch (System.DllNotFoundException e)
310 {
311 Log.Info(
312 "Could not connect to Tilt Five plugin for setting max glasses: {0}",
313 e.Message);
314 }
315 catch (System.Exception e)
316 {
317 Log.Error(e.Message);
318 }
319
320 // Initialize the player settings if necessary
321 for (int i = 0; i < allPlayerSettings.Length; i++)
322 {
323 var currentPlayerSettings = allPlayerSettings[i];
324 if (currentPlayerSettings == null)
325 {
327 }
328 }
329
331
332 for (int i = 0; i < supportedPlayerCount; i++)
333 {
334 var playerSettings = allPlayerSettings[i];
335 if (playerSettings != null)
336 {
337 Player.Reset(playerSettings, spectatorSettings);
338 }
339 }
340
341#if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
342 InputSystem.onBeforeUpdate += OnBeforeUpdate;
343#endif
344 }
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 370 of file TiltFiveManager2.cs.

371 {
372 try
373 {
375 }
376 catch (System.DllNotFoundException)
377 {
378 // nothing to report on quit if the plugin isn't present
379 }
380 catch (System.Exception e)
381 {
382 Log.Error(e.Message);
383 }
384 }
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 392 of file TiltFiveManager2.cs.

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

388 {
389 Application.quitting += Quit;
390 }

References TiltFive.TiltFiveManager2.Quit().

◆ Update()

void TiltFive.TiltFiveManager2.Update ( )
private

Update this instance.

Definition at line 198 of file TiltFiveManager2.cs.

199 {
200#if !UNITY_2019_1_OR_NEWER || !INPUTSYSTEM_AVAILABLE
202 Player.ScanForNewPlayers(); // Should only be executed once per frame
203 Wand.GetLatestInputs(); // Should only be executed once per frame
204#endif
206
207 for (int i = 0; i < supportedPlayerCount; i++)
208 {
209 var playerSettings = allPlayerSettings[i];
210 if (playerSettings != null)
211 {
212 Player.Update(playerSettings, spectatorSettings);
213 }
214 }
215
216 var spectatedPlayer = spectatorSettings.spectatedPlayer;
217 if (Glasses.TryGetPreviewPose(spectatedPlayer, out var spectatedPlayerPose))
218 {
219 spectatorSettings.spectatorCamera?.transform.SetPositionAndRotation(
220 spectatedPlayerPose.position,
221 spectatedPlayerPose.rotation);
222 }
223 }
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
bool NeedsDriverUpdate()
Check if a driver update is needed.
The Wand API and runtime.
Definition: Wand.cs:56

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.TryGetPreviewPose().

Member Data Documentation

◆ allPlayerSettings

◆ 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

◆ 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 {
100 allPlayerSettings[3] = new PlayerSettings() { PlayerIndex = PlayerIndex.Four };
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 {
55 allPlayerSettings[0] = new PlayerSettings() { PlayerIndex = PlayerIndex.One };
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 {
85 allPlayerSettings[2] = new PlayerSettings() { PlayerIndex = PlayerIndex.Three };
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 {
70 allPlayerSettings[1] = new PlayerSettings() { PlayerIndex = PlayerIndex.Two };
71 }
72 return allPlayerSettings[1];
73 }
74 }

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