Crowd Control Manager
The Crowd Control Manager Script
First, import the appropriate Crowd Control Package for your project. It can be found at: https://github.com/WarpWorld/CrowdControl.Client.Unity.Package/.
Adding and Modifying the Manager Script
The Crowd Control Manager drives all of the Crowd Control commands during gameplay. To locate the script:
- Create a new empty GameObject in your scene and name it "Crowd Control".
- Click on the newly created GameObject and go to the inspector. Click on "Add Component" and search for "CrowdControlBehavior". Add the script to the GameObject.
- Observe the inspector and you will see the Crowd Control Manager's fields that you can modify.
Manager Script Fields
The script has the following fields that you can modify:

Game ID Required
The ID for your game is labeled as "UnityDemo," which is the default used for testing. After you submit an application for your game, you'll be assigned a specific Game ID.
Display Name Required
The name of the game that will be displayed to viewers in the stream's Crowd Control Menu.
Application ID Required
The Application ID is a unique identifier for your game, which is used to authenticate and connect to the Crowd Control server. You will receive this ID when you register your game with Crowd Control.
Public Client Key Required
The Public Client Key is a key that is used in conjunction with the Application ID to authenticate your game with the Crowd Control server.
Game State Manager Required
The Game State Manager is a script that you can create to manage the state of your game. It should implement the IGameStateManager interface, which includes methods for handling game state changes and effect triggers. You can create your own Game State Manager script and assign it to this field in the Crowd Control Manager.
Effect Loader Required
The Effect Loader is a script that you can create to load and manage the effects in your game. It should implement the IEffectLoader interface. It is recommded to use the provided UnityEffectLoader script, which can be found in the Crowd Control Client Unity Package. You can assign your custom Effect Loader script to this field in the Crowd Control Manager.
Metadata Loader
The Metadata Loader is a script that you can create to load and manage the metadata for your game. It should implement the IMetadataLoader interface. It is recommended to use the provided UnityMetadataLoader script, which can be found in the Crowd Control Client Unity Package. You can assign your custom Metadata Loader script to this field in the Crowd Control Manager.
Auto Connect
Whether to automatically connect to the Crowd Control server when the manager is initialized.
Wait for Ping Response
Whether to wait for a ping response from the Crowd Control server before proceeding with certain actions. This option is primarily used for debugging purposes and is not necessary for most applications.
Persist Login Token
Whether to persist the login token across sessions, allowing automatic login in future sessions.
Preserve Between Scenes
Whether to preserve the manager when switching between scenes.
Manager Script Events
The script has the following events that you can subscribe to:

Session Ready
Invoked when the Crowd Control session is ready. This can be used to trigger in-game responses to the session being ready.
Session Ended
Invoked when the Crowd Control session has ended. This can be used to trigger in-game responses to the session ending.
Auth Code Received
Invoked whenever an authentication code is received from the Crowd Control service. This can be used to trigger in-game responses to authentication events.
Auth Code Redeemed Received
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.
Auth Code Error Received
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.
Login Token Received
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.
Effect Received
Invoked whenever an effect request is received from the Crowd Control service. This can be used to trigger in-game responses to effect requests.
Effect Update
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.
Manager Script Test Commands
The script has the following test commands that can be fired from the editor:

Connect
Manually connect to the Crowd Control server.
Ping Test
Send a ping request to the Crowd Control server to test connectivity and latency.
Clear Login Token
Clear the persisted login token, if any.
Launch Interact Link
Launch the Crowd Control Interact Link in the default web browser. The Interact Link is a web page that allows users to interact with the Crowd Control session and trigger effects.
Create Menu JSON
Generate a JSON file containing the current effects and metadata. This file is used by the Crowd Control service to populate the stream's Crowd Control menu.
