Search Unity

[bug/feature] android StreamingAssets bundles loading without UnityWebRequests

Discussion in 'Addressables' started by nik_d, Jun 12, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    workaround: in AssetBundleProvider.cs
    in ComputeSize(...)

    Code (CSharp):
    1. #if UNITY_ANDROID //**addressables: Android StreamingAssets fix
    2.             if (loc.InternalId.Contains(":///")) {
    3.                 // StreamingAssets on Android:
    4.                 //    support for "jar:file:///data/app/com.playkot.ageofmagic/..." format
    5.                 return 0;
    6.             }
    7. #endif
    in BeginOperation(...)

    Code (CSharp):
    1.             if (File.Exists(path)
    2. #if UNITY_ANDROID //**addressables: Android StreamingAssets fix
    3.                 // StreamingAssets on Android:
    4.                 //    support for "jar:file:///data/app/com.playkot.ageofmagic/..." format
    5.                 // File.Exists doesn't work: https://forum.unity.com/threads/cant-use-json-file-from-streamingassets-on-android-and-ios.472164/#post-3384671
    6.                 // try Application.dataPath + "!assets/": https://forum.unity.com/threads/assetbundle-load-question.402376/#post-2679871
    7.                 || path.Contains(":///")
    8. #endif
    9.             )
    10.  
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Can you elaborate on the point of this change? Is there actually a bug with using UWR? Or do you just not like it on principal and want to change it?
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    I think you should be able to load asset bundle from streaming assets using AssetBundle.LoadFromFile/Async.
     
  4. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    The fix at least brings us to the same behaviour on device and in editor.

    Possibly UnityWebRequestAssetBundle does internally AssetBundle.LoadFromFileAsync, but I was surprised when saw them in log.)
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    No, but both these APIs come down to the same reading from file code.
     
  6. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Ah, seems like our info was partially out of date. For content catalogs (or any raw files) we need to still load via UWR (I think), but for asset bundles specifically, we can use LoadFromFileAsync.

    I'll file a bug in our system to work on this