Search Unity

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

Question Custom Asset Bundle Resource is preventing upgrade from 1.18.9

Discussion in 'Addressables' started by bex_unity, Nov 12, 2021.

  1. bex_unity

    bex_unity

    Joined:
    May 29, 2019
    Posts:
    4
    I'm trying to upgrade our team's project to version 1.19+ and I've run into trouble. In our project we're using a custom Asset Bundle Resource, which implements IAssetBundleResource, so we can prevent automatic downloads and control that manually ourselves.

    Between versions 1.18.9 and 1.18.19, BundledAssetProvider.InternalOp.LoadBundleFromDependecies(IList<object> results) changed. This change isn't listed in the changelog as far as I can see - it used to be this:

    Code (CSharp):
    1. internal static AssetBundleResource LoadBundleFromDependecies(IList<object> results)
    2. {
    3.     if (results == null || results.Count == 0)
    4.         return null;
    5.  
    6.     AssetBundleResource bundle = null;
    7.     bool firstBundleWrapper = true;
    8.     for (int i = 0; i < results.Count; i++)
    9.     {
    10.         var abWrapper = results[i] as IAssetBundleResource;
    11.         if (abWrapper != null)
    12.         {
    13.             //only use the first asset bundle, even if it is invalid
    14.             abWrapper.GetAssetBundle();
    15.             if (firstBundleWrapper)
    16.                 bundle = abWrapper;
    17.             firstBundleWrapper = false;
    18.         }
    19.     }
    20.     return bundle;
    21. }
    Now, the first line in the for loop is this:

    Code (CSharp):
    1. var abWrapper = results[i] as AssetBundleResource;
    This causes BundledAssetProvider.Start to fail with an exception with a message beginning "Unable to load dependent bundle from location ", and consequently all our addressable asset loads fail.

    AssetBundleResource is an internal class so we can't change our custom class to inherit from it. Is it possible to revert this method to use the interface again, to allow for our scenario? Thanks.
     
    kou-yeung likes this.
  2. chris_hellsten

    chris_hellsten

    Joined:
    May 5, 2014
    Posts:
    12
    Great find! We have exactly the same issue and are stranded on 1.18.9 for the same reason. Even worse is that in the latest 2020 LTS (2020.3.21), Addressables package is force-updated passed 1.18.9 to a version that doesn't work for custom asset bundle providers.

    +1 for please reverting this change!
     
    kou-yeung likes this.
  3. kou-yeung

    kou-yeung

    Joined:
    Sep 5, 2016
    Posts:
    30
    i have same issue for this.
    in BundledAssetProvider.cs
    Code (CSharp):
    1. public void Start(ProvideHandle provideHandle)
    2. {
    3.     var bundleResource = LoadBundleFromDependecies(deps);
    4.     //...
    5.     m_PreloadRequest = bundleResource.GetAssetPreloadRequest();
    6.  
    7. }
    it directly call the AssetBundleResource.GetAssetPreloadRequest()
    it is very hard to create the custom asset bundle providers..

    i think some game developer just want to custom the download and load process for custom encryption or anything they want.
    ( e.g. use UnityWebRequest / AssetBundle.LoadFromFileAsync to download and use assets from storage )

    I hope Unity team can provide an easier extension method for this.
     
    Last edited: Nov 15, 2021
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    959
    Just embed the package and edit. We do that as a matter of course.
     
  5. RYL123

    RYL123

    Joined:
    May 17, 2017
    Posts:
    4
    I ran into the same problem recently.
    When I customize AssetBundleProvider with version 1.16.19, there is no problem. But when I upgraded to 1.18.16 , the problem appeared.
    At present, the temporary solution for my project is to copy the source code of BundledAssetProvider in 1.16.19, implement a similar BundledAssetProvider in the project, and use it with CustomAssetbundleProvider.
    It seems to work normally until now, but I am not at ease, there may be flaws in doing so.
    Hope Unity official can solve this extension problem.
     
    Last edited: Dec 20, 2021
  6. bex_unity

    bex_unity

    Joined:
    May 29, 2019
    Posts:
    4
    Update: looks like this was fixed in 1.19.13 (screenshot taken from the release notes thread on the forum)
     

    Attached Files:

    RYL123 and davidla_unity like this.
  7. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    @bex_unity thanks for pointing out that change log entry. If anyone still has issues with this in 1.19.13+ please let us know and go ahead and file a bug. If you file a bug and post on the forums, please post the ticket number in there so I can look it up whenever I see it.