Suspends coroutine execution until the provided player has connected. More...
Public Member Functions | |
WaitUntilPlayerConnected (PlayerIndex playerIndex) | |
Properties | |
override bool | keepWaiting [get] |
Private Attributes | |
PlayerIndex | playerIndex = PlayerIndex.One |
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); }
TiltFive.Player.WaitUntilPlayerConnected.WaitUntilPlayerConnected | ( | PlayerIndex | playerIndex | ) |
Definition at line 432 of file Player.cs.
References TiltFive.Player.WaitUntilPlayerConnected.playerIndex.
|
private |
Definition at line 430 of file Player.cs.
Referenced by TiltFive.Player.WaitUntilPlayerConnected.WaitUntilPlayerConnected().
|
get |