Suspends coroutine execution until the provided player's wand has connected. More...
Public Member Functions | |
WaitUntilWandConnected (PlayerIndex playerIndex, ControllerIndex controllerIndex) | |
Properties | |
override bool | keepWaiting [get] |
Private Attributes | |
PlayerIndex | playerIndex = PlayerIndex.One |
ControllerIndex | controllerIndex = ControllerIndex.Right |
Suspends coroutine execution until the provided player's wand has connected.
This custom yield instruction is useful for performing tasks that depend on a specific player's wand being connected and initialized. This is a tidy alternative to polling Wand.TryCheckConnected(out bool, PlayerIndex, ControllerIndex) in a loop or using UnityEngine.WaitUntil.
Let's assume we are making a game that requires both wands (left and right) from a specific player to be connected.
We may want to display a prompt for the specified player to connect both of their wands, update the prompt as the wands are connected, then dismiss the prompt once the player is ready.
private IEnumerator PromptPlayerForBothWands(PlayerIndex targetPlayer) { // Let's assume this coroutine is part of a script with a member variable called playerConnectivityPrompt. // Start by defining some text asking the player to connect their left and right wands, then revealing the prompt. playerConnectivityPrompt.SetText("Waiting for left and right wands..."); playerConnectivityPrompt.Show();
// Suspend this coroutine until the player's right wand has connected. yield return new WaitUntilWandConnected(targetPlayer, ControllerIndex.Right);
// Adjust the prompt text now that we know that the right wand is connected. playerConnectivityPrompt.SetText("Waiting for left wand...");
// Suspend this coroutine until the player's left wand has connected. yield return new WaitUntilWandConnected(targetPlayer, ControllerIndex.Left);
// Now that both wands are connected, we can hide the prompt and end the coroutine. playerConnectivityPrompt.Hide(); }
TiltFive.Wand.WaitUntilWandConnected.WaitUntilWandConnected | ( | PlayerIndex | playerIndex, |
ControllerIndex | controllerIndex | ||
) |
Definition at line 1253 of file Wand.cs.
References TiltFive.Wand.WaitUntilWandConnected.controllerIndex, and TiltFive.Wand.WaitUntilWandConnected.playerIndex.
|
private |
Definition at line 1251 of file Wand.cs.
Referenced by TiltFive.Wand.WaitUntilWandConnected.WaitUntilWandConnected().
|
private |
Definition at line 1250 of file Wand.cs.
Referenced by TiltFive.Wand.WaitUntilWandConnected.WaitUntilWandConnected().
|
get |