Tilt Five™ Unity API  1.4.1
TiltFive.Player.WaitUntilPlayerConnected Class Reference

Suspends coroutine execution until the provided player has connected. More...

Inheritance diagram for TiltFive.Player.WaitUntilPlayerConnected:

Public Member Functions

 WaitUntilPlayerConnected (PlayerIndex playerIndex)
 

Properties

override bool keepWaiting [get]
 

Private Attributes

PlayerIndex playerIndex = PlayerIndex.One
 

Detailed Description

Suspends coroutine execution until the provided player has connected.

This custom yield instruction is useful for performing tasks that depend on a specific player being connected and initialized. This is a tidy alternative to repeatedly polling Player.IsConnected(PlayerIndex) in a loop or using UnityEngine.WaitUntil.

Let's assume that we've written a script that needs to cache the player's head pose root GameObject in a member variable for later use. The head pose root GameObject doesn't exist until the specified player connects and creates it during initialization, so we need to wait for the player to connect.

private IEnumerator Start() { // ... // We can do some other initialization here before we begin waiting. // ...

// Suspend this coroutine until the specified player has connected. yield return new Player.WaitUntilPlayerConnected(PlayerIndex.Two);

// Now that the player has connected, it is safe to obtain and store the player's head pose root GameObject. m_glassesPoseRoot = Glasses.GetPoseRoot(PlayerIndex.Two); }

Definition at line 427 of file Player.cs.

Constructor & Destructor Documentation

◆ WaitUntilPlayerConnected()

TiltFive.Player.WaitUntilPlayerConnected.WaitUntilPlayerConnected ( PlayerIndex  playerIndex)

Definition at line 432 of file Player.cs.

433  {
434  this.playerIndex = playerIndex;
435  }

References TiltFive.Player.WaitUntilPlayerConnected.playerIndex.

Member Data Documentation

◆ playerIndex

PlayerIndex TiltFive.Player.WaitUntilPlayerConnected.playerIndex = PlayerIndex.One
private

Property Documentation

◆ keepWaiting

override bool TiltFive.Player.WaitUntilPlayerConnected.keepWaiting
get

Definition at line 429 of file Player.cs.


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