Table of Contents

Class GltfImporter

Namespace
S1MAPI.Gltf
Assembly
S1MAPI_Mono.dll

Fluent importer for GLB and GLTF files. Provides a chainable API for configuring and executing imports.

public sealed class GltfImporter
Inheritance
GltfImporter
Inherited Members

Examples

GameObject model = new GltfImporter()
    .SetName("MyModel")
    .SetShader(myShader)
    .SetScale(0.01f)
    .ImportAnimations(true)
    .Load(glbBytes);

Constructors

GltfImporter()

Creates a new GLTF importer with default options.

public GltfImporter()

GltfImporter(GltfImportOptions)

Creates a new GLTF importer with the specified options.

public GltfImporter(GltfImportOptions options)

Parameters

options GltfImportOptions

Import options controlling the loading behavior. Create a GltfImportOptions instance to configure how the model is imported.

Methods

GenerateNormals(bool)

Configures whether to generate normals for meshes lacking them.

public GltfImporter GenerateNormals(bool generate)

Parameters

generate bool

True to generate missing normals

Returns

GltfImporter

This importer for method chaining

GenerateTangents(bool)

Configures whether to generate tangents for normal mapping.

public GltfImporter GenerateTangents(bool generate)

Parameters

generate bool

True to generate missing tangents

Returns

GltfImporter

This importer for method chaining

ImportAnimations(bool)

Configures whether to import animations.

public GltfImporter ImportAnimations(bool import)

Parameters

import bool

True to import animations

Returns

GltfImporter

This importer for method chaining

ImportBlendShapes(bool)

Configures whether to import blend shapes.

public GltfImporter ImportBlendShapes(bool import)

Parameters

import bool

True to import blend shapes

Returns

GltfImporter

This importer for method chaining

ImportCameras(bool)

Configures whether to import cameras.

public GltfImporter ImportCameras(bool import)

Parameters

import bool

True to import cameras

Returns

GltfImporter

This importer for method chaining

ImportSkins(bool)

Configures whether to import skins for skeletal animation.

public GltfImporter ImportSkins(bool import)

Parameters

import bool

True to import skins

Returns

GltfImporter

This importer for method chaining

Load(byte[])

Loads a GLB or GLTF model from a byte array. Automatically detects format based on magic number.

public GameObject? Load(byte[] data)

Parameters

data byte[]

GLB or JSON bytes

Returns

GameObject

The root GameObject of the imported model, or null on failure

LoadFromFile(string)

Loads a GLTF model from a file path. Supports both .glb and .gltf files.

public GameObject? LoadFromFile(string filePath)

Parameters

filePath string

Path to the GLTF/GLB file

Returns

GameObject

The root GameObject of the imported model, or null on failure

LoadGlb(byte[])

Loads a GLB model from a byte array.

public GameObject? LoadGlb(byte[] glbBytes)

Parameters

glbBytes byte[]

Raw GLB file bytes

Returns

GameObject

The root GameObject of the imported model, or null on failure

LoadGltfJson(string, string?)

Loads a GLTF model from JSON text.

public GameObject? LoadGltfJson(string json, string? basePath)

Parameters

json string

GLTF JSON string

basePath string

Base path for resolving external resources

Returns

GameObject

The root GameObject of the imported model, or null on failure

ReadableMeshes(bool)

Configures whether meshes should be readable from CPU.

public GltfImporter ReadableMeshes(bool readable)

Parameters

readable bool

True to keep meshes readable

Returns

GltfImporter

This importer for method chaining

SetEmissionIntensity(float)

Sets the emission intensity multiplier for emissive materials. Values greater than 1.0 create HDR emission for neon/glow effects. Also reads and applies the KHR_materials_emissive_strength extension if present.

public GltfImporter SetEmissionIntensity(float intensity)

Parameters

intensity float

Emission multiplier (default is 1.0)

Returns

GltfImporter

This importer for method chaining

SetName(string)

Sets the name for the root GameObject.

public GltfImporter SetName(string name)

Parameters

name string

Name for the imported model

Returns

GltfImporter

This importer for method chaining

SetScale(float)

Sets the scale factor for the model.

public GltfImporter SetScale(float scale)

Parameters

scale float

Scale multiplier

Returns

GltfImporter

This importer for method chaining

SetShader(Shader)

Sets the shader to use for materials.

public GltfImporter SetShader(Shader shader)

Parameters

shader Shader

Shader for materials (null for Standard)

Returns

GltfImporter

This importer for method chaining