InworldController
Module: Inworld.AI. Namespace: Inworld. RequireComponent: InworldClient, AudioCapture, CharacterHandler. Inherited from: SingletonBehavior.
The InworldController acts as the API hub within a Unity application, primarily designed for backward compatibility with previous versions.
It serves as a central point for managing API interfaces, ensuring that the system maintains its interfaces with older versions while delegating the actual execution of each API call to subordinate scripts.
Inspector Variables
Variable | Description |
---|---|
Game Data | The current InworldGameData component used to load scenes. |
Scene Full Name | If GameData is null, specifying this string will also work for loading scenes. |
Properties
Property | Description |
---|---|
HasError | Returns true if any InworldError was received from the Inworld server. |
Audio | Provides access to the AudioCapture component of the InworldController. |
CharacterHandler | Provides access to the CharacterHandler component of the InworldController. |
Client | Provides access to the InworldClient component of the InworldController. |
Status | Retrieves the current connection status. |
CurrentWorkspace | Retrieves the full name of the current workspace. |
CurrentScene | Retrieves the full name of the current InworldScene. |
CurrentCharacter | Gets/Sets the current interacting InworldCharacter. |
GameData | Gets or sets the InworldGameData associated with the InworldController. |
API
Function | Description | Parameters |
---|---|---|
LoadData | Loads the InworldGameData and sets client's related data if the game data is not null. | gameData: The InworldGameData to load. |
InitWithCustomToken | Initializes the SDK using a custom token instead of API key/secret. This token can be obtained from other applications, such as the InworldWebSDK. | token: The custom token for initialization. |
Reconnect | Reconnects the session or starts a new session if the current session is invalid. | |
Init | Initializes the SDK. | |
LoadScene | Sends a LoadScene request to the Inworld Server. In ver 3.3 or further, the session must be connected first. | sceneFullName: The full string of the scene to load. |
PrepareSession | Sent after the ClientStatus is set to Connected. Sequentially sends Session Config parameters, enabling this session to become interactive. | |
Disconnect | Disconnects from the Inworld Server. | |
SendText | Sends text messages in the current scene. If there's a current character, it'll be sent to the specific character, otherwise, it'll be sent as broadcast. | text: The message to send. |
SendNarrativeAction | Sends a narrative action in the current scene. If there's a current character, it'll be sent to the specific character, otherwise, it'll be sent as broadcast. | narrativeAction: The narrative action to send. |
CancelResponse | Cancels response generation for all characters currently generating responses. Automatically used when sending Text. For other sending data, such as sending trigger, please consider to use according to your scenario. | |
SendCancelEvent | Sends the CancelResponse Event to the InworldServer to interrupt the character's speaking. | interactionID: The handle of the dialog context that needs to be canceled. utteracneID: the handle of the current utterance that needs to be cancelled. |
SendWorldTrigger | Send the trigger to the whole session. | triggerName: the name of the trigger to send. |
SendTrigger | Sends a trigger to an InworldCharacter in the current scene. | charID: The live session ID of the character to send. Send to World if it's empty triggerName: The name of the trigger to send. parameters: The parameters and their values for the triggers. |
StartAudio | Sends AUDIO_SESSION_START control events to the server. Without sending this message, all audio data would be discarded by the server. However, if you send this event twice in a row, without sending StopAudio() , Inworld server will also throw exceptions and terminate the session. | |
StopAudio | Sends AUDIO_SESSION_END control events to Inworld server. | |
SendAudio | Sends the WAV data to the current character. Ensure that an AUDIO_SESSION_START control event has been sent to the server. Only the base64 string of the wave data is supported by the Inworld server. Additionally, the sample rate of the wave data must be 16000, mono channel. | base64: the base64 string of the wave data to send. |
PushAudio | Manually pushes the audio wave data to the server. |