docs.unity3d.com
    Show / Hide Table of Contents

    Class EntityInstantiator

    Inheritance
    Object
    EntityInstantiator
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: GLTFast
    Syntax
    public class EntityInstantiator : IInstantiator

    Constructors

    EntityInstantiator(IGltfReadable, Entity, ICodeLogger, InstantiationSettings)

    Declaration
    public EntityInstantiator(IGltfReadable gltf, Entity parent, ICodeLogger logger = null, InstantiationSettings settings = null)
    Parameters
    Type Name Description
    IGltfReadable gltf
    Entity parent
    ICodeLogger logger
    InstantiationSettings settings

    Fields

    m_Gltf

    Declaration
    protected IGltfReadable m_Gltf
    Field Value
    Type Description
    IGltfReadable

    m_Logger

    Declaration
    protected ICodeLogger m_Logger
    Field Value
    Type Description
    ICodeLogger

    m_Nodes

    Declaration
    protected Dictionary<uint, Entity> m_Nodes
    Field Value
    Type Description
    Dictionary<UInt32, Entity>

    m_Parent

    Declaration
    protected Entity m_Parent
    Field Value
    Type Description
    Entity

    m_Settings

    Declaration
    protected InstantiationSettings m_Settings
    Field Value
    Type Description
    InstantiationSettings

    Methods

    AddAnimation(AnimationClip[])

    Adds animation clips to the current scene. Only available if the built-in Animation module is enabled.

    Declaration
    public void AddAnimation(AnimationClip[] animationClips)
    Parameters
    Type Name Description
    AnimationClip[] animationClips

    Animation clips

    Implements
    IInstantiator.AddAnimation(AnimationClip[])

    AddCamera(UInt32, UInt32)

    Called when a node has a camera assigned

    Declaration
    public void AddCamera(uint nodeIndex, uint cameraIndex)
    Parameters
    Type Name Description
    UInt32 nodeIndex

    Index of the node

    UInt32 cameraIndex

    Index of the assigned camera

    Implements
    IInstantiator.AddCamera(UInt32, UInt32)

    AddLightPunctual(UInt32, UInt32)

    Called when a node has a punctual light assigned (KHR_lights_punctual)

    Declaration
    public void AddLightPunctual(uint nodeIndex, uint lightIndex)
    Parameters
    Type Name Description
    UInt32 nodeIndex

    Index of the node

    UInt32 lightIndex

    Index of the punctual light

    Implements
    IInstantiator.AddLightPunctual(UInt32, UInt32)

    AddPrimitive(UInt32, String, Mesh, Int32[], UInt32[], Nullable<UInt32>, Single[], Int32)

    Called for adding a Primitive/Mesh to a Node.

    Declaration
    public virtual void AddPrimitive(uint nodeIndex, string meshName, Mesh mesh, int[] materialIndices, uint[] joints = null, uint? rootJoint = null, float[] morphTargetWeights = null, int primitiveNumeration = 0)
    Parameters
    Type Name Description
    UInt32 nodeIndex

    Index of the node

    String meshName

    Mesh's name

    Mesh mesh

    The actual Mesh

    Int32[] materialIndices

    Material indices. Should be used to query the material

    UInt32[] joints

    If a skin was attached, the joint indices. Null otherwise

    Nullable<UInt32> rootJoint

    Root joint node index, if present

    Single[] morphTargetWeights

    Morph target weights, if present

    Int32 primitiveNumeration

    Primitives are numerated per Node, starting with 0

    Implements
    IInstantiator.AddPrimitive(UInt32, String, Mesh, Int32[], UInt32[], Nullable<UInt32>, Single[], Int32)

    AddPrimitiveInstanced(UInt32, String, Mesh, Int32[], UInt32, Nullable<NativeArray<Vector3>>, Nullable<NativeArray<Quaternion>>, Nullable<NativeArray<Vector3>>, Int32)

    Called for adding a Primitive/Mesh to a Node that uses GPU instancing (EXT_mesh_gpu_instancing) to render the same mesh/material combination many times. Similar to/called instead of AddPrimitive(UInt32, String, Mesh, Int32[], UInt32[], Nullable<UInt32>, Single[], Int32), without joints/skin support.

    Declaration
    public void AddPrimitiveInstanced(uint nodeIndex, string meshName, Mesh mesh, int[] materialIndices, uint instanceCount, NativeArray<Vector3>? positions, NativeArray<Quaternion>? rotations, NativeArray<Vector3>? scales, int primitiveNumeration = 0)
    Parameters
    Type Name Description
    UInt32 nodeIndex

    Index of the node

    String meshName

    Mesh's name

    Mesh mesh

    The actual Mesh

    Int32[] materialIndices

    Material indices. Should be used to query the material

    UInt32 instanceCount

    Number of instances

    Nullable<NativeArray<Vector3>> positions

    Instance positions

    Nullable<NativeArray<Quaternion>> rotations

    Instance rotations

    Nullable<NativeArray<Vector3>> scales

    Instance scales

    Int32 primitiveNumeration

    Primitives are numerated per Node, starting with 0

    Implements
    IInstantiator.AddPrimitiveInstanced(UInt32, String, Mesh, Int32[], UInt32, Nullable<NativeArray<Vector3>>, Nullable<NativeArray<Quaternion>>, Nullable<NativeArray<Vector3>>, Int32)

    BeginScene(String, UInt32[])

    Starts creating a scene instance. Has to be called at first and concluded by calling EndScene(UInt32[]).

    Declaration
    public void BeginScene(string name, uint[] nodeIndices)
    Parameters
    Type Name Description
    String name

    Name of the scene

    UInt32[] nodeIndices
    Implements
    IInstantiator.BeginScene(String, UInt32[])

    CreateNode(UInt32, Nullable<UInt32>, Vector3, Quaternion, Vector3)

    Called for every Node in the glTF file

    Declaration
    public void CreateNode(uint nodeIndex, uint? parentIndex, Vector3 position, Quaternion rotation, Vector3 scale)
    Parameters
    Type Name Description
    UInt32 nodeIndex

    Index of node. Serves as identifier.

    Nullable<UInt32> parentIndex

    Index of the parent's node. If it's null, the node's a root-level node

    Vector3 position

    Node's local position in hierarchy

    Quaternion rotation

    Node's local rotation in hierarchy

    Vector3 scale

    Node's local scale in hierarchy

    Implements
    IInstantiator.CreateNode(UInt32, Nullable<UInt32>, Vector3, Quaternion, Vector3)

    EndScene(UInt32[])

    Is called at last, after all scene content has been created. Immediately afterwards the scene will be rendered, so use it to finally prepare the instance.

    Declaration
    public virtual void EndScene(uint[] rootNodeIndices)
    Parameters
    Type Name Description
    UInt32[] rootNodeIndices

    Indices of root level nodes in scene

    Implements
    IInstantiator.EndScene(UInt32[])

    SetNodeName(UInt32, String)

    Declaration
    public void SetNodeName(uint nodeIndex, string name)
    Parameters
    Type Name Description
    UInt32 nodeIndex
    String name
    Implements
    IInstantiator.SetNodeName(UInt32, String)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023