Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Load RuntimeAnimatorController from addressable

Discussion in 'Addressables' started by jiahongzeng, Sep 17, 2019.

  1. jiahongzeng

    jiahongzeng

    Joined:
    Jul 24, 2019
    Posts:
    18
    Hi

    I try to load RuntimeAnimatorController from addressable(version 1.2.3).
    Here is the my code.
    Code (CSharp):
    1. Addressables.LoadAssetAsync<RuntimeAnimatorController>("RuntimeAnimatorControllerKey").Completed += InitData;
    It works fine in unity.
    But when I run on mobile.It shows error
    Is someone bump into the same error?
     
    Last edited: Sep 17, 2019
  2. taptpci

    taptpci

    Joined:
    Jan 31, 2018
    Posts:
    8
    As a workaround, Have you considered using Addressables to load a GameObject that has an Animator component that references your AnimatorController, and then obtaining a RuntimeAnimatorController from the loaded Animator component?
     
  3. jiahongzeng

    jiahongzeng

    Joined:
    Jul 24, 2019
    Posts:
    18
    Hi,thanks for the reply.

    It may works but I make it plan B.
    In that way,I need to make the AnimatorController to a prefab.
    When I load successful I have to do one more step to get the asset.
    It is not much convenient so I just want to know is there has more efficient to get the AnimatorController.

    Thanks.
     
  4. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    459
    The system shall support prefab and scriptable object, but not component (yet). Caused by the limitation of the underlying asset bundle.
     
  5. rg_johnokane

    rg_johnokane

    Joined:
    Oct 10, 2018
    Posts:
    11
    In V1.2.2 it looks like a possible issue in AddressableAssetEntry.cs : CreateCatalogEntries. There should be a conversion like the SceneAsset -> SceneInstance but for AnimatorController -> RuntimeAnimatorController (the CheckForEditorAssembly method has no effect even though it alters the type reference passed in).

    Try adding this below the SceneAsset check and see if it helps:

    Code (CSharp):
    1.             if (mainType == typeof(SceneAsset))
    2.                 mainType = typeof(SceneInstance);
    3.                
    4.             if (mainType == typeof(Animations.AnimatorController))
    5.             {
    6.                 mainType = typeof(RuntimeAnimatorController);
    7.             }
    8.  
     
  6. alia_0

    alia_0

    Joined:
    Nov 28, 2012
    Posts:
    17
    @rg_johnokane thanks for that! This works in v1.4.0 as a fix.
     
    rg_johnokane and Colin_MacLeod like this.
  7. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    130
    nice! i stumbled on this post not even realizing this would have been an issue. I was wondering why my RuntimeAnimatorController addressable was failing only on the quest.
     
  8. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    130
    So this was a premature celebration. The above fix mentioned did not work for me. Still can't load RuntimeAnimatorController on mobile. Its telling me the key is invalid? Works on windows builds fine.
     
  9. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    704
    Hey @Jribs I think we have a fix for this coming soon (likely in the next week or two). Our fix ended up being a little different so I'll make sure that mobile gets tested since you're having problems with that
     
  10. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    174
    @Jribs The fix seems to work for me with 1.4.0 on iOS?
     
  11. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    174
    Hmm but just found out it doesn't seem to work for a colleague. Maybe it's only working sometimes
     
  12. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    704
    @Colin_MacLeod so we fixed the issue on our side where we weren't converting the Editor type to the Runtime type but, unfortunately, there appears to be a bug on the engine side with some aspects of animation serialization. So that may be what your colleague is running into. Maybe not but I just wanted to throw that out there.
     
    taptpci and Colin_MacLeod like this.
  13. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    174
    Thanks for that. Is there any ETA on a solution?
     
  14. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    704
    I know a solution is under way. I'm not 100% on how far along they are though. Since it's an engine issue I'm hopeful that they'll have it done in time to get it in for the next Unity release but I can't really speak to that. If I hear anything else I'll try and come back to update this thread.
     
    Colin_MacLeod likes this.
  15. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    174
    Thanks for that
     
  16. NikoBay

    NikoBay

    Joined:
    Aug 15, 2018
    Posts:
    39
    now is July, 2020 and the bug is still here. Anyone has any updates or workaround (which is more likely to happen)?
     
unityunity