docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IGltfWritable

    Is able to receive asset resources and export them to glTF

    Namespace: GLTFast.Export
    Assembly: glTFast.Export.dll
    Syntax
    public interface IGltfWritable

    Methods

    AddCamera(Camera, out int)

    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

    int cameraId

    glTF camera index

    Returns
    Type Description
    bool

    True if camera was successfully created, false otherwise

    AddCameraToNode(int, int)

    Assigns a camera to a previously added node

    Declaration
    void AddCameraToNode(int nodeId, int cameraId)
    Parameters
    Type Name Description
    int nodeId

    Index of the node to add the mesh to

    int 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
    int

    glTF image index

    AddLight(Light, out int)

    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

    int lightId

    glTF light index

    Returns
    Type Description
    bool

    True if light was successfully created, false otherwise

    AddLightToNode(int, int)

    Assigns a light to a previously added node

    Declaration
    void AddLightToNode(int nodeId, int lightId)
    Parameters
    Type Name Description
    int nodeId

    Index of the node to add the mesh to

    int lightId

    glTF light ID to be assigned

    AddMaterial(Material, out int, IMaterialExport)

    Adds a Unity material

    Declaration
    bool AddMaterial(Material uMaterial, out int materialId, IMaterialExport materialExport)
    Parameters
    Type Name Description
    Material uMaterial

    Unity material

    int materialId

    glTF material index

    IMaterialExport materialExport

    Material converter

    Returns
    Type Description
    bool

    True if converting and adding material was successful, false otherwise

    AddMeshToNode(int, Mesh, int[])

    Assigns a mesh to a previously added node

    Declaration
    [Obsolete("Use overload with skinning parameter.")]
    void AddMeshToNode(int nodeId, Mesh uMesh, int[] materialIds)
    Parameters
    Type Name Description
    int nodeId

    Index of the node to add the mesh to

    Mesh uMesh

    Unity mesh to be assigned and exported

    int[] materialIds

    glTF materials IDs to be assigned (multiple in case of sub-meshes)

    AddMeshToNode(int, Mesh, int[], bool)

    Assigns a mesh to a previously added node

    Declaration
    void AddMeshToNode(int nodeId, Mesh uMesh, int[] materialIds, bool skinning)
    Parameters
    Type Name Description
    int nodeId

    Index of the node to add the mesh to

    Mesh uMesh

    Unity mesh to be assigned and exported

    int[] materialIds

    glTF materials IDs to be assigned (multiple in case of sub-meshes)

    bool skinning

    Skinning has been applied (e.g. SkinnedMeshRenderer).

    AddNode(float3?, quaternion?, float3?, uint[], 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
    float3? translation

    Local translation of the node (in Unity-space)

    quaternion? rotation

    Local rotation of the node (in Unity-space)

    float3? scale

    Local scale of the node (in Unity-space)

    uint[] children

    Array of node indices that are parented to this newly created node

    string name

    Name of the node

    Returns
    Type Description
    uint

    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
    int

    glTF sampler index or -1 if no sampler is required

    AddScene(uint[], string)

    Adds a scene to the glTF

    Declaration
    uint AddScene(uint[] nodes, string name = null)
    Parameters
    Type Name Description
    uint[] nodes

    Root level nodes

    string name

    Name of the scene

    Returns
    Type Description
    uint

    glTF scene index

    AddTexture(int, int)

    Creates a glTF texture from with a given image index

    Declaration
    int AddTexture(int imageId, int samplerId)
    Parameters
    Type Name Description
    int imageId

    glTF image index returned by AddImage(ImageExportBase)

    int samplerId

    glTF sampler index returned by AddSampler(FilterMode, TextureWrapMode, TextureWrapMode)

    Returns
    Type Description
    int

    glTF texture index

    RegisterExtensionUsage(Extension, bool)

    Registers the use of a glTF extension

    Declaration
    void RegisterExtensionUsage(Extension extension, bool required = true)
    Parameters
    Type Name Description
    Extension extension

    Extension's name

    bool 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<bool>

    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<bool>

    True if the glTF file was created successfully, false otherwise

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)