InworldGraphExecutor | Inherits from: MonoBehaviour
Component responsible for executing Inworld AI graph assets within Unity. Manages the lifecycle of graph compilation, execution, and result handling for AI-powered workflows. Provides event-driven architecture for monitoring graph state and receiving output data.
Properties
Methods
Events
Reference
The graph executor is the independent hub of the graph engine. Assign a graph asset in editor or at runtime, then compile it to make it executable.
Graph
Gets or sets the graph asset to be executed by this component. When set, clears the current compilation state and runtime objects.Returns
Type:InworldGraphAsset
Error
Gets or sets the current error message from graph operations. When set, automatically logs the error and triggers the OnGraphError event.Returns
Type:string
IsCompiled
Gets a value indicating whether the current graph has been successfully compiled.Returns
Type:bool
IsExecuting
Gets a value indicating whether the graph is currently executing.Returns
Type:bool
RuntimeGraph
Gets the runtime instance of the compiled graph. Returns null if no graph is loaded or compilation failed.Returns
Type:InworldGraph
IsInitialized
Gets a value indicating whether the graph executor is initialized and ready for execution.Returns
Type:bool
LoadData
Loads a new graph asset for execution, replacing the current one. Cannot be called while a graph is currently executing. Automatically clears compilation state and runtime objects.Parameters
| Parameter | Type | Description |
|---|---|---|
| graphAsset | InworldGraphAsset | The graph asset to load for execution. |
Returns
Type:void
Compile
Compiles the current graph asset into a runtime executable form. Must be called before executing the graph. Triggers OnGraphCompiled event on success or OnGraphError on failure.Parameters
| Parameter | Type | Description |
|---|---|---|
| compiled | CompiledGraphInterface | Optional compiled graph interface. |
Returns
Type:bool
Description: True if compilation succeeded, false otherwise.
ExecuteGraphAsync
Executes the compiled graph asynchronously with optional input data. The graph must be compiled before execution can begin. Supports both streaming and simplified execution modes.Parameters
| Parameter | Type | Description |
|---|---|---|
| executorName | string | Optional identifier for this execution instance. If empty, a GUID will be generated. |
| input | InworldBaseData | Optional input data to provide to the graph. If null, an empty InworldBaseData will be used. |
Returns
Type:Awaitable<bool>
Description: A task that completes with true if execution started successfully, false otherwise.
StopExecution
Stops the current graph execution if one is running. Closes all active executions and triggers the OnGraphFinished event.Returns
Type:void
CleanupRuntimeObjects
Cleans up all runtime objects associated with the current graph. Resets compilation and execution state to allow for fresh graph loading.Returns
Type:void
OnGraphCompiled
Event triggered when a graph asset has been successfully compiled and is ready for execution.Parameters
| Parameter | Type | Description |
|---|---|---|
| graphAsset | InworldGraphAsset | The compiled graph asset. |
OnGraphStarted
Event triggered when graph execution begins.Parameters
| Parameter | Type | Description |
|---|---|---|
| graphAsset | InworldGraphAsset | The graph asset that started execution. |
OnGraphResult
Event triggered when the graph produces a result during execution. Provides access to intermediate and final output data from the graph.Parameters
| Parameter | Type | Description |
|---|---|---|
| result | InworldBaseData | The result data produced by the graph. |
OnGraphFinished
Event triggered when graph execution completes successfully.Parameters
| Parameter | Type | Description |
|---|---|---|
| graphAsset | InworldGraphAsset | The graph asset that finished execution. |
OnGraphError
Event triggered when an error occurs during graph compilation or execution.Parameters
| Parameter | Type | Description |
|---|---|---|
| graphAsset | InworldGraphAsset | The graph asset that encountered an error. |
| errorMessage | string | The error message describing what went wrong. |