Interface IPrefabInstantiationProvider
Contract for a prefab instantiation strategy.
Implementations of this interface must be MonoBehaviours attached to the ElasticSceneGenerator and provide a PrefabInstantiationContext to the pipeline to be used by IPipelineWorkers that need to instantiate prefabs.
Inherited Members
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Runtime.dll
Syntax
public interface IPrefabInstantiationProvider : IContextProvider
Methods
Despawn(GameObject)
Releases an instance previously obtained via Spawn(GameObject, Vector3, Quaternion, Vector3, Func<GameObject, UniTask>, CancellationToken).
Declaration
bool Despawn(GameObject instance)
Parameters
Type | Name | Description |
---|---|---|
GameObject | instance | The instance to release. |
Returns
Type | Description |
---|---|
bool | Whether the implementation handled the specified instance. When this returns |
InitAsync(GameObject, Action<GameObject>, CancellationToken)
Creates initial instances of the specified prefab.
Declaration
UniTask InitAsync(GameObject prefab, Action<GameObject> initAction = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | The prefab to instantiate. |
Action<GameObject> | initAction | Optional initial action to invoke specific initialization behavior. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
Spawn(GameObject, Vector3, Quaternion, Vector3, Func<GameObject, UniTask>, CancellationToken)
Creates an instance of the specified prefab.
Declaration
UniTask<(bool Success, GameObject Result)> Spawn(GameObject prefab, Vector3 position, Quaternion rotation, Vector3 scale, Func<GameObject, UniTask> preSpawnAction = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | The prefab to spawn. |
Vector3 | position | The global position to place the instance at. |
Quaternion | rotation | The global rotation to set on the instance. |
Vector3 | scale | The scale to set on the instance. |
Func<GameObject, Cysharp.Threading.Tasks.UniTask> | preSpawnAction | Func delegate to be invoked before the GameObject is activated. Currently used for graph data injection. |
CancellationToken | cancellationToken | Token to cancel the async UniTask operation. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask<T><(bool Success, GameObject Result)> | Indicates whether an instance was created. When this returns |