Search Unity

(custom provider) ProvideHandle stays at 0.5 even though asset bundle is successfully retrieved

Discussion in 'Addressables' started by movingdimensions, Apr 30, 2021.

  1. movingdimensions

    movingdimensions

    Joined:
    Jan 9, 2015
    Posts:
    18
    I'm using the following a custom provider code to download content from PlayFab CDN (code is from GameDev Guru, if someone wants to look it up, it's a great write up and guide).

    The issue is that it is correctly retrieving the URL and downloading the content. You can see this in the last yellow pointed line (5). The asset name in the bundle is printed correctly. However the first yellow line (1) that called the load stays stuck at 0.5 percent and never finishes.

    What could be causing this?


    image direct link: https://i.imgur.com/MzpDnWZ.jpg

    Code:
    Code (CSharp):
    1. [DisplayName("PlayFab Asset Bundle Provider")]
    2.     public class PlayFabStorageAssetBundleProvider : AssetBundleProvider
    3.     {
    4.         public override void Provide(ProvideHandle provideHandle)
    5.         {
    6.             Debug.Log("PlayFabStorageAssetBundleProvider: " + provideHandle.Location.InternalId);
    7.             var addressableId = provideHandle.Location.InternalId.Replace("playfab://", "");
    8.             PlayFabClientAPI.GetContentDownloadUrl(
    9.                 new GetContentDownloadUrlRequest() { Key = addressableId, ThruCDN = false },
    10.                 result =>
    11.                 {
    12.                     Debug.Log("URL available: " + result.URL);
    13.                     var dependenciesList = provideHandle.Location.Dependencies;
    14.                     var dependenciesArray = provideHandle.Location.Dependencies == null ? new IResourceLocation[0] : new IResourceLocation[dependenciesList.Count];
    15.                     dependenciesList?.CopyTo(dependenciesArray, 0);
    16.                     var resourceLocation = new ResourceLocationBase(result.URL, result.URL, typeof(AssetBundleProvider).FullName, typeof(IResourceLocator), dependenciesArray)
    17.                     {
    18.                         Data = provideHandle.Location.Data,
    19.                         PrimaryKey = provideHandle.Location.PrimaryKey
    20.                     };
    21.                     provideHandle.ResourceManager.ProvideResource<IAssetBundleResource>(resourceLocation).Completed += handle =>
    22.                     {
    23.                         Debug.Log("Resources downloaded");
    24.                         var contents = handle.Result;
    25.                         var names = contents.GetAssetBundle().GetAllAssetNames();
    26.                         for (int i = 0; i < names.Length; i++)
    27.                         {
    28.                             Debug.Log(names[i]);
    29.                         }
    30.                         provideHandle.Complete(contents, true, handle.OperationException);
    31.                     };
    32.                 },
    33.                 error => Debug.LogError(error.GenerateErrorReport()));
    34.         }
    35.     }
     
  2. movingdimensions

    movingdimensions

    Joined:
    Jan 9, 2015
    Posts:
    18
    For anyone coming across this. The issue was due to a part of my code using allowSceneActivation, which as it was pointed out to me by a lurking ninja, is a no go for Addressables.
     
    dimmduh1 likes this.