Interface IBufferDataConsumer
Consumes a glTF asset's buffer data during import, once every buffer is loaded and decoded and before the import converts that data into Unity resources. To use this, implement the interface in an ImportAddonInstance and inject that instance.
Namespace: Unity.Cloud.Gltfast.Addons
Assembly: Unity.Cloud.Gltfast.dll
Syntax
public interface IBufferDataConsumer
Remarks
Add-ons implementing this are invoked in unspecified order and potentially concurrently, so an implementation must not assume that it is the only one running, or that it runs before or after any other add-on.
Methods
ConsumeBufferDataAsync(IGltfBufferData, CancellationToken)
Called once all of the glTF asset's buffers are available and decoded, before their data is converted into Unity resources.
Declaration
Task<bool> ConsumeBufferDataAsync(IGltfBufferData bufferData, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IGltfBufferData | bufferData | Read access to the asset's buffer data. It is disposed by the import right after this call returns. To keep reading beyond it, lease your own via LeaseBufferData() and dispose that when done. |
| CancellationToken | cancellationToken | Can be used to abort the loading procedure. |
Returns
| Type | Description |
|---|---|
| Task<bool> | False if the loading process has to be aborted due to a critical error. True otherwise. |
Remarks
Called on the main thread and has to return on it. In between it may schedule C# jobs
or start threads of its own. Use bufferData itself from the main
thread only; the containers it provides may be read from those jobs and threads.
The glTF asset is read-only here. An implementation must not modify Root, any glTF object or any buffer data. It is free to allocate, decode and create resources of its own, which it then owns.
Returning false aborts the import. Whether the remaining add-ons are invoked, or run to completion, is unspecified. Report the reason through the import's ICodeLogger; the return value only signals success.