Interface IGltfWritable
Is able to receive asset resources and export them to glTF
Namespace: GLTFast.Export
Syntax
public interface IGltfWritable
Methods
AddCamera(Camera, out Int32)
Creates a glTF camera based on a Unity camera
Declaration
bool AddCamera(Camera uCamera, out int cameraId)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera | uCamera | Unity camera |
| Int32 | cameraId | glTF camera index |
Returns
| Type | Description |
|---|---|
| Boolean | True if camera was successfully created, false otherwise |
AddCameraToNode(Int32, Int32)
Assigns a camera to a previously added node
Declaration
void AddCameraToNode(int nodeId, int cameraId)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nodeId | Index of the node to add the mesh to |
| Int32 | cameraId | glTF camera ID to be assigned |
AddImage(ImageExportBase)
Adds an ImageExport to the glTF and returns the resulting image index
Declaration
int AddImage(ImageExportBase imageExport)
Parameters
| Type | Name | Description |
|---|---|---|
| ImageExportBase | imageExport | Image to be exported |
Returns
| Type | Description |
|---|---|
| Int32 | glTF image index |
AddLight(Light, out Int32)
Creates a glTF light based on a Unity light Uses the KHR_lights_punctual extension.
Declaration
bool AddLight(Light uLight, out int lightId)
Parameters
| Type | Name | Description |
|---|---|---|
| Light | uLight | Unity light |
| Int32 | lightId | glTF light index |
Returns
| Type | Description |
|---|---|
| Boolean | True if light was successfully created, false otherwise |
AddLightToNode(Int32, Int32)
Assigns a light to a previously added node
Declaration
void AddLightToNode(int nodeId, int lightId)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nodeId | Index of the node to add the mesh to |
| Int32 | lightId | glTF light ID to be assigned |
AddMaterial(Material, out Int32, IMaterialExport)
Adds a Unity material
Declaration
bool AddMaterial(Material uMaterial, out int materialId, IMaterialExport materialExport)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | uMaterial | Unity material |
| Int32 | materialId | glTF material index |
| IMaterialExport | materialExport | Material converter |
Returns
| Type | Description |
|---|---|
| Boolean | True if converting and adding material was successful, false otherwise |
AddMeshToNode(Int32, Mesh, Int32[])
Assigns a mesh to a previously added node
Declaration
void AddMeshToNode(int nodeId, Mesh uMesh, int[] materialIds)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | nodeId | Index of the node to add the mesh to |
| Mesh | uMesh | Unity mesh to be assigned and exported |
| Int32[] | materialIds | glTF materials IDs to be assigned (multiple in case of sub-meshes) |
AddNode(Nullable<float3>, Nullable<quaternion>, Nullable<float3>, UInt32[], String)
Adds a node to the glTF
Declaration
uint AddNode(float3? translation = null, quaternion? rotation = null, float3? scale = null, uint[] children = null, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Nullable<float3> | translation | Local translation of the node (in Unity-space) |
| Nullable<quaternion> | rotation | Local rotation of the node (in Unity-space) |
| Nullable<float3> | scale | Local scale of the node (in Unity-space) |
| UInt32[] | children | Array of node indices that are parented to this newly created node |
| String | name | Name of the node |
Returns
| Type | Description |
|---|---|
| UInt32 | glTF node index |
AddSampler(FilterMode, TextureWrapMode, TextureWrapMode)
Creates a glTF sampler based on Unity filter and wrap settings
Declaration
int AddSampler(FilterMode filterMode, TextureWrapMode wrapModeU, TextureWrapMode wrapModeV)
Parameters
| Type | Name | Description |
|---|---|---|
| FilterMode | filterMode | Texture filter mode |
| TextureWrapMode | wrapModeU | Texture wrap mode in U direction |
| TextureWrapMode | wrapModeV | Texture wrap mode in V direction |
Returns
| Type | Description |
|---|---|
| Int32 | glTF sampler index or -1 if no sampler is required |
AddScene(UInt32[], String)
Adds a scene to the glTF
Declaration
uint AddScene(uint[] nodes, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| UInt32[] | nodes | Root level nodes |
| String | name | Name of the scene |
Returns
| Type | Description |
|---|---|
| UInt32 | glTF scene index |
AddTexture(Int32, Int32)
Creates a glTF texture from with a given image index
Declaration
int AddTexture(int imageId, int samplerId)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | imageId | glTF image index returned by AddImage(ImageExportBase) |
| Int32 | samplerId | glTF sampler index returned by AddSampler(FilterMode, TextureWrapMode, TextureWrapMode) |
Returns
| Type | Description |
|---|---|
| Int32 | glTF texture index |
RegisterExtensionUsage(Extension, Boolean)
Registers the use of a glTF extension
Declaration
void RegisterExtensionUsage(Extension extension, bool required = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Extension | extension | Extension's name |
| Boolean | required | True if extension is required and used. False if it's used only |
SaveToFileAndDispose(String)
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
Task<bool> SaveToFileAndDispose(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| String | path | glTF destination file path |
Returns
| Type | Description |
|---|---|
| Task<Boolean> | True if the glTF file was created successfully, false otherwise |
SaveToStreamAndDispose(Stream)
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
Task<bool> SaveToStreamAndDispose(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | glTF destination stream |
Returns
| Type | Description |
|---|---|
| Task<Boolean> | True if the glTF file was created successfully, false otherwise |