ClientConnection Callbacks
The "ClientConnection" is the "Player" that is spawned for each connecting client. These are the available callbacks that you can tie into a particular client connection component.
Available Callbacks
| Name | Type | Description |
|---|---|---|
| OnPlayerCharacterChanged | GameObject | Called whenever the _playerCharacter has changed. Supplies the new gameobject in the invokation. |
| OnPlayerNameChanged | string | Called whenever the playerName value has changed. Supplies the new value in the invokation. |
| OnPlayerDeadChanged | bool | Called when the isDead value has changed. Supplies the current isDead status in the invokation. |
| OnPlayerHealthChanged | int | Called when the playerHealth value has changed. Supplies the current playerHealth value in the invokation. |
| OnPlayerMaxHealthChanged | int | Called when the playerMaxHealth value has changed. Supplies the current playerMaxHealth value in the invokation. |
| OnSceneChanged | string | Called when the inScene value has changed. Supplies the current inScene value in the invokation. |
Example Tie In
The following is the proper way to register and deregister functions with these available delegates:
ClientConnection conn;
protected virtual void OnEnable()
{
conn = ClientUtil.GetClientConnection(target_gameobject);
conn.OnPlayerNameChanged += NameChanged;
conn.OnPlayerCharacterChanged += CharacterChanged;
}
protected virtual void OnDisable()
{
if (conn == null) return;
conn.OnPlayerNameChanged -= NameChanged;
conn.OnPlayerCharacterChanged -= CharacterChanged;
}
public virtual void NameChanged(string newName)
{
...
}
public virtual void CharacterChanged(GameObject newCharacterObj)
{
...
}