CrowdControlBehavior
Inherits MonoBehaviour
Public Member Functions
void
Releases all resources used by this component and disconnects from Crowd Control.
void
Initializes and connects the Crowd Control client.
void
Launches the interact link URL in the user's default web browser.
string?
Gets the interact link URL from the Crowd Control client.
void
Disconnects from the Crowd Control service and disposes the client instance.
void
Clears the stored JWT token, forcing a full re-authentication on the next connection attempt.
void
Sends a ping to the Crowd Control service and logs the result.
Task
This method attempts to stop all running effects via the Crowd Control effect scheduler. This will return false if any of the effect stop functions throw an exception.
bool
Attempts to get a metadata object from the Crowd Control client. This method will return false if the metadata loader is not initialized, if the specified key does not exist in the metadata, or if the value cannot be cast to TValue.
bool
Attempts to retrieve a metadata value from the Crowd Control client. This method will return false if the metadata loader is not initialized, if the specified key does not exist in the metadata, or if the value cannot be cast to TValue.
bool
Attempts to retrieve a metadata value from the Crowd Control client. This method will return false if the metadata loader is not initialized, if the specified key does not exist in the metadata, or if the value cannot be cast to TValue.
void
Updates custom effects in the Crowd Control system by loading effects from the configured effect loader using merge mode. This operation runs asynchronously and requires both a valid Crowd Control connection and an assigned EffectLoader. If either prerequisite is not met, an error is logged and no update is performed. Only custom effects are included in the update.
bool
Documentation inherited from WebSocket.CrowdControl.CloneEffect.
Task
Documentation inherited from WebSocket.CrowdControl.ShowEffects(string[]).
Task
Documentation inherited from WebSocket.CrowdControl.ShowEffects(IEnumerable<string>, string?).
Task
Documentation inherited from WebSocket.CrowdControl.ShowAllEffects(string?).
Task
Documentation inherited from WebSocket.CrowdControl.HideEffects(string[]).
Task
Documentation inherited from WebSocket.CrowdControl.HideEffects(IEnumerable<string>, string?).
Task
Documentation inherited from WebSocket.CrowdControl.HideAllEffects(string?).
Task
Documentation inherited from WebSocket.CrowdControl.EnableEffects(string[]).
Task
Documentation inherited from WebSocket.CrowdControl.EnableEffects(IEnumerable<string>, string?).
Task
Documentation inherited from WebSocket.CrowdControl.EnableAllEffects(string?).
Task
Documentation inherited from WebSocket.CrowdControl.DisableEffects(string[]).
Task
Documentation inherited from WebSocket.CrowdControl.DisableEffects(IEnumerable<string>, string?).
Task
Documentation inherited from WebSocket.CrowdControl.DisableAllEffects(string?).
Public Static Functions
void
Clears the stored JWT token, forcing a full re-authentication on the next connection attempt.
Private Functions
void
Unity callback invoked when the component is enabled. Initializes and connects the Crowd Control client if autoConnect is enabled.
void
Stops and disposes the Crowd Control client instance, if any.
void
Unity physics update loop; forwards timing to the Crowd Control client for processing.
void
Unity callback invoked when the component is destroyed; ensures disposal.
Protected Functions
void
Finalizer to ensure resources are released if Dispose() wasn't called.
void
Core dispose pattern implementation.
Public Attributes
string
GameID
The game identifier used when connecting to the Crowd Control service.
string
DisplayName
The display name used when connecting to the Crowd Control service.
string
ApplicationID
The application identifier used for authentication with the Crowd Control service.
UnityGameStateManager?
GameStateManager
Component that provides the current WebSocket.GameState to Crowd Control.
UnityEffectLoader?
EffectLoader
Component responsible for finding and registering UnityEffectBase instances.
UnityMetadataLoader?
MetadataLoader
Component responsible for finding and registering UnityMetadataBase instances.
bool
AutoConnect
Whether to automatically connect to Crowd Control on start.
bool
AutoReconnect
Whether to automatically reconnect to Crowd Control when the connection is lost while a session is active.
bool
AutoAddCustomEffects
Whether to automatically add custom effects defined in the EffectLoader to the service on startup.
bool
WaitForPingResponse
Whether to block on ping responses. This is for testing purposes only and should generally be false in production.
bool
PersistLoginToken
Whether to persist the JWT token for reconnecting between executions.
bool
PreserveBetweenScenes
Whether to preserve the manager when switching between scenes.
UnityEvent?
SessionReadyEvent
UnityEvent invoked when the Crowd Control session is ready. This can be used to trigger in-game responses to the session being ready. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeReceived event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent?
SessionEndedEvent
UnityEvent invoked when the Crowd Control session has ended. This can be used to trigger in-game responses to the session ending. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the SessionEnded event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
AuthCodeReceivedEvent
UnityEvent invoked whenever an authentication code is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeReceived event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
AuthCodeRedeemedReceivedEvent
UnityEvent invoked whenever an authentication code redemption result is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeRedeemedReceived event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
AuthCodeErrorReceivedEvent
UnityEvent invoked whenever an authentication code error is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeErrorReceived event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
LoginTokenReceivedEvent
UnityEvent invoked whenever a JWT login token is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the LoginTokenReceived event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
EffectReceivedEvent
UnityEvent invoked whenever an effect request is received from the Crowd Control service. This can be used to trigger in-game responses to effect requests. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the EffectReceived event, but not both, to avoid duplicate handling of effect requests. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
UnityEvent
EffectUpdateEvent
UnityEvent invoked whenever an effect class update is sent to the Crowd Control service. This can be used to trigger in-game responses to effect class updates. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the EffectUpdate event, but not both, to avoid duplicate handling of effect updates. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Private Attributes
string?
m_jwt
Backing field for the JWT token used for authentication with the Crowd Control service. This is set when a new token is received and is used for reconnecting if the connection is lost.
Properties
bool
HasValidToken
[get, ]
Gets a value indicating whether there is a valid JWT token available for authentication with the Crowd Control service.
bool
Connected
[get, ]
Gets a value indicating whether the Crowd Control client is currently connected. True if the client is created and connected; false otherwise.
Scheduler
Scheduler
[get, ]
Gets the Scheduler instance used by the Crowd Control client for scheduling effect execution. Throws an exception if the client is not initialized.
WebSocket.CrowdControl?
CrowdControl
[get, ]
bool
IsDisposed
[get, ]
Gets a value indicating whether this component has been disposed.
static
bool
IsStoredTokenValid
[get, ]
Gets a value indicating whether there is a valid JWT token stored for authentication with the Crowd Control service.
bool
IsTokenValid
[get, ]
Gets a value indicating whether the currently stored JWT token is valid for authentication with the Crowd Control service.
Events
Action
SessionReady
Event invoked when the Crowd Control session is ready. This can be used to trigger in-game responses to the session being ready. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the SessionReadyEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
SessionEnded
Event invoked when the Crowd Control session has ended. This can be used to trigger in-game responses to the session ending. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the SessionEndedEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(ApplicationAuthCode)
AuthCodeReceived
Event invoked whenever an authentication code is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeReceivedEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(ApplicationAuthCodeRedeemed)
AuthCodeRedeemedReceived
Event invoked whenever an authentication code redemption result is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeRedeemedReceivedEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(ApplicationAuthCodeError)
AuthCodeErrorReceived
Event invoked whenever an authentication code error is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the AuthCodeErrorReceivedEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(string)
LoginTokenReceived
Event invoked whenever a JWT login token is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the LoginTokenReceivedEvent event, but not both, to avoid duplicate handling of authentication events. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(EffectRequest)
EffectReceived
Event invoked whenever an effect request is received from the Crowd Control service. This can be used to trigger in-game responses to effect requests. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the EffectReceivedEvent event, but not both, to avoid duplicate handling of effect requests. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(EffectState)
EffectUpdate
Event invoked whenever an effect class update is sent to the Crowd Control service. This can be used to trigger in-game responses to effect class updates. Note that this event is invoked on the Unity main thread, so it's safe to perform Unity operations in response to it. Subscribers should use either this event or the EffectUpdateEvent event, but not both, to avoid duplicate handling of effect updates. This event is invoked between Update() and LateUpdate() in the Unity lifecycle, so it will be processed after all Update() calls but before any LateUpdate() calls.
Action
(IEnumerable
MetadataChanged
