Tilt Five™ Unity API  1.4.1
TiltFive.Wand.WaitUntilWandConnected Class Reference

Suspends coroutine execution until the provided player's wand has connected. More...

Inheritance diagram for TiltFive.Wand.WaitUntilWandConnected:

Public Member Functions

 WaitUntilWandConnected (PlayerIndex playerIndex, ControllerIndex controllerIndex)
 

Properties

override bool keepWaiting [get]
 

Private Attributes

PlayerIndex playerIndex = PlayerIndex.One
 
ControllerIndex controllerIndex = ControllerIndex.Right
 

Detailed Description

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(); }

Definition at line 1245 of file Wand.cs.

Constructor & Destructor Documentation

◆ WaitUntilWandConnected()

TiltFive.Wand.WaitUntilWandConnected.WaitUntilWandConnected ( PlayerIndex  playerIndex,
ControllerIndex  controllerIndex 
)

Member Data Documentation

◆ controllerIndex

ControllerIndex TiltFive.Wand.WaitUntilWandConnected.controllerIndex = ControllerIndex.Right
private

◆ playerIndex

PlayerIndex TiltFive.Wand.WaitUntilWandConnected.playerIndex = PlayerIndex.One
private

Property Documentation

◆ keepWaiting

override bool TiltFive.Wand.WaitUntilWandConnected.keepWaiting
get

Definition at line 1247 of file Wand.cs.


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