Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation doesn't work on android! #238

Open
Robo233 opened this issue Feb 22, 2023 · 0 comments
Open

Animation doesn't work on android! #238

Robo233 opened this issue Feb 22, 2023 · 0 comments

Comments

@Robo233
Copy link

Robo233 commented Feb 22, 2023

I used this code to download the model from the web. It is a .gltf version of a model from https://www.mixamo.com/#/

 public IEnumerator DownloadModelCoroutine(string url, string path){
    if(File.Exists(path)){
        Debug.Log("Found model locally");
        LoadModel(path);
    }else{
        using (UnityWebRequest webRequest = UnityWebRequest.Get(url)){
            webRequest.downloadHandler = new DownloadHandlerBuffer();
            yield return webRequest.SendWebRequest();
            if(webRequest.result == UnityWebRequest.Result.ConnectionError || webRequest.result == UnityWebRequest.Result.ProtocolError){
                Debug.Log(webRequest.error);
                model = null;
            }else{
                File.WriteAllBytes(path, webRequest.downloadHandler.data);
                LoadModel(path);
            }
        }
    }
}

And this for the animation:

void LoadModel(string path){
    AnimationClip[] animClips;
    var i = new ImportSettings();
    i.useLegacyClips = true;
    model = Importer.LoadFromFile(path,i, out animClips);
    if (animClips.Length > 0){
        Animation anim = model.AddComponent<Animation>();
        animClips[0].legacy = true;
        animClips[0].wrapMode = WrapMode.Loop;
        anim.clip = animClips[0];
        anim.Play();
    }
}

It works perfectly in the editor, but after I build it for android, the model is loaded but the animation doesn't work. I'm using Unity 2022.2.7 and also tried Unity 2022.1.23 and Unity 2021.3.19. I also tried different versions of the GLTFUtility package. I tried with both .gltf and .glb files but it doesn't work. I used the Android Logcat and it says "Default clip could not be found in attached animations list".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant