ChatBox - Delegates
If you want to call other component functions based on actions in the chatbox, here is a list of available delegates you can tie into:
| Delegate Name | Returns | Description |
|---|---|---|
| OnActiveChannelChanged | Int | Called everytime the activeChannel of the chatbox is changed. It returns the current activeChannel that is now set. |
| OnChannelMembersUpdated | List |
Called everytime channel members leave or join one of the channels you are a member of. Returns the entire list of channel members. |
| OnReceiveChannelInvite | Dictionary<int, string> | Called when you receive an invite to a channel. |
| OnAnyNewChatMessage | -- | Called anytime a new message shows up in any channel you're a member of. |
| OnNewActiveChannelMessage | -- | Called anytime a new message shows up in your currently active channel. |
| OnChatBoxStatusChanged | bool | Called anytime the chatbox is enabled or disabled. Returns the previous state and the new state. |
Basic Tie In Example
protected virtual IEnumerator RegisterWithChatBox()
{
yield return new WaitUntil(() => ChatBox.instance != null);
ChatBox.instance.OnReceiveChannelInvite += ReceivedNewInvite;
}
protected virtual void OnEnable()
{
StartCoroutine(RegisterWithChatBox());
}
protected virtual void OnDestroy()
{
if (ChatBox.instance != null)
ChatBox.instance.OnReceiveChannelInvite -= ReceivedNewInvite;
}
public virtual void ReceivedNewInvite(Dictionary<int, string> item)
{
...
...
}
Lock Character Movement Example
The following will show you how to lock the camera and character movement by taking advantage of the above delegates.
Make a script and attach to the root of your character.
using Invector.vCharacterController;
using Invector.vCamera;
...
...
protected virtual void OnEnable()
{
ChatBox.instance.OnChatBoxStatusChanged += ChatBoxStatusChanged;
}
protected virtual void OnDisable()
{
ChatBox.instance.OnChatBoxStatusChanged -= ChatBoxStatusChanged;
}
protected virtual void ChatBoxStatusChanged(bool isEnabled)
{
GetComponent<vThirdPersonInput>().SetLockAllInput(isEnabled);
GetComponent<vThirdPersonInput>().SetLockCameraInput(isEnabled);
}