GLTFUtility icon indicating copy to clipboard operation
GLTFUtility copied to clipboard

async sample code has a bug

Open HawkenKing opened this issue 4 years ago • 5 comments

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Siccity.GLTFUtility;
public class ModelLoader : MonoBehaviour
{
    public string filename;
    public void OnLoadTest()
    {
        ImportGLTFAsync(filename);
    }
    void ImportGLTFAsync(string filepath) {
        Importer.ImportGLTFAsync(filepath, new ImportSettings(), OnFinishAsync);
    }
    void OnFinishAsync(GameObject result) {
        Debug.Log("Finished importing " + result.name);
    }
}

OnFinishAsync will redline in VSCode and Unity (line 13)

Is there a way to correct the third part of Importer.ImportGLTFAsync() to fix this?

HawkenKing avatar Mar 25 '20 10:03 HawkenKing

fixed for now like this:

void ImportGLTFAsync(string filepath) {
    Importer.ImportGLTFAsync(filepath, new ImportSettings(), OnFinishAsync);
}
void OnFinishAsync(GameObject result, GLTFAnimation.ImportResult[] air) {
    Debug.Log("Finished importing " + result.name);
}

HawkenKing avatar Mar 25 '20 10:03 HawkenKing

I think I'm having the same issue. The suggested fix is also not working. The async example code won't compile. It says:

cannot convert from 'method group' to 'Action<GameObject, AnimationClip[]>'

grafik

Did anything change in the source code?

LoLoLonny avatar May 09 '20 18:05 LoLoLonny

Try adding , AnimationClip[] animations to OnFinishAsync paramers

Siccity avatar May 10 '20 17:05 Siccity

Hi, @Siccity . I tried your suggested fix, but still didn't work. Any idea of what may fix this? It works fine when i want to load a single .gltf file, but doesn't load the textures when they aren't embeded in the file.

debfdias avatar Aug 13 '20 11:08 debfdias

, AnimationClip[] animations

This worked for me. Maybe change the code on the readme file?

Thebinoman avatar Jul 11 '21 13:07 Thebinoman