Skip to content

Importing glTF file from byte array #395

Answered by atteneder
Zamaroth asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
Granted, that example code is not clear at all.

It's meant like so:

async void LoadGltfBinaryFromMemory() {
    var filePath = "/path/to/file.glb";
    byte[] data = File.ReadAllBytes(filePath);
    var gltf = new GltfImport();
    bool success = await gltf.LoadGltfBinary(data, new Uri(filePath));
    if (success) {
        success = gltf.InstantiateMainScene(transform);
    }
}

So the URI provided is the one of the .gltf file. It'll be used as reference for relative URIs within the JSON.

hth

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Zamaroth
Comment options

@atteneder
Comment options

@atteneder
Comment options

@Zamaroth
Comment options

Answer selected by Zamaroth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants