Class GameObjectExport
Creates glTF files from GameObject hierarchies
Inherited Members
Namespace: GLTFast.Export
Assembly: glTFast.Export.dll
Syntax
public class GameObjectExport
Constructors
GameObjectExport(ExportSettings, GameObjectExportSettings, IMaterialExport, IDeferAgent, ICodeLogger)
Provides glTF export of GameObject based scenes and hierarchies.
Declaration
public GameObjectExport(ExportSettings exportSettings = null, GameObjectExportSettings gameObjectExportSettings = null, IMaterialExport materialExport = null, IDeferAgent deferAgent = null, ICodeLogger logger = null)
Parameters
Type | Name | Description |
---|---|---|
ExportSettings | exportSettings | Export settings |
GameObjectExportSettings | gameObjectExportSettings | GameObject export settings |
IMaterialExport | materialExport | Provides material conversion |
IDeferAgent | deferAgent | Defer agent (<see cref="IDeferAgent"/>); decides when/if to preempt export to preserve a stable frame rate. |
ICodeLogger | logger | Interface for logging (error) messages. |
Methods
AddScene(ICollection<GameObject>, float4x4, string)
Creates a glTF scene from a collection of GameObjects. The GameObjects will be converted into glTF nodes. The nodes' positions within the glTF scene will be their GameObjects' world position transformed by the origin matrix, essentially allowing you to set an arbitrary scene center.
Declaration
public bool AddScene(ICollection<GameObject> gameObjects, float4x4 origin, string name)
Parameters
Type | Name | Description |
---|---|---|
ICollection<GameObject> | gameObjects | Root level GameObjects (will get added recursively) |
float4x4 | origin | Inverse scene origin matrix. This transform will be applied to all nodes. |
string | name | Name of the scene |
Returns
Type | Description |
---|---|
bool | True if the scene was added successfully, false otherwise |
AddScene(GameObject[], string)
Adds a scene to the glTF which consists of a collection of GameObjects.
Declaration
public bool AddScene(GameObject[] gameObjects, string name = null)
Parameters
Type | Name | Description |
---|---|---|
GameObject[] | gameObjects | GameObjects to be added (recursively) as root level nodes. |
string | name | Name of the scene |
Returns
Type | Description |
---|---|
bool | True, if the scene was added flawlessly. False, otherwise |
SaveToFileAndDispose(string, CancellationToken)
Exports the collected scenes/content as glTF, writes it to a file and disposes this object. After the export this instance cannot be re-used!
Declaration
public Task<bool> SaveToFileAndDispose(string path, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | path | glTF destination file path |
CancellationToken | cancellationToken | Token to submit cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task<bool> | True if the glTF file was created successfully, false otherwise |
SaveToStreamAndDispose(Stream, CancellationToken)
Exports the collected scenes/content as glTF, writes it to a Stream and disposes this object. Only works for self-contained glTF-Binary. After the export this instance cannot be re-used!
Declaration
public Task<bool> SaveToStreamAndDispose(Stream stream, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | glTF destination stream |
CancellationToken | cancellationToken | Token to submit cancellation requests. The default value is None. |
Returns
Type | Description |
---|---|
Task<bool> | True if the glTF file was written successfully, false otherwise |