Search Unity

Can't load any assets in Windows build

Discussion in 'Addressables' started by Silly_Rollo, May 24, 2020.

  1. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Everything works fine in the editor but after a build absolutely none of my assets can be loaded. They all error in the player.log with

    "Exception encountered in operation Resource<Object>(defaultlocalgroup_assets_all_2cec2b1b3e9fd2fb1cae21b46af71526.bundle): Unable to load dependent bundle from location C:/Projects/Builds/RiftRiders/Rift Riders_Data/StreamingAssets/aa/Windows/StandaloneWindows64/defaultlocalgroup_assets_all_2cec2b1b3e9fd2fb1cae21b46af71526.bundle "

    and

    "Exception encountered in operation Resource<Sprite>(A_Fist.png[A_Fist]): Dependency Exception "

    for all files.

    I'm loading them directly from the AssetReference with "AssetReference.LoadAssetAsync<T>().Completed += CompleteLoad;" so I'm not relying on any strings or keys.

    The docs are still pretty bare and unclear on what needs to be set on the simplest setup. I have one group and just want to load assets. These are my settings:

    upload_2020-5-23_16-39-37.png

    This is my group:
    upload_2020-5-23_16-40-6.png

    Any ideas? I'm not sure where to go since it just doesn't work in a build
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    I'll forward this thread to the team for them to have a look. Which version of Addressables are you using?
     
  3. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
  4. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    I updated to the newest Addressables version (hadn't noticed there was a newer one) and getting a different error message:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3.   at UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.Execute () [0x00010] in <dfa5fa8b644b4d859b4509577494eb97>:0
    4.   at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () [0x00000] in <ac5bd3d8b9f74d4e85e3bae81d3663cc>:0
    5.   at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList`1[T] updateCallbacks) [0x00068] in <ac5bd3d8b9f74d4e85e3bae81d3663cc>:0
    6.   at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00000] in <ac5bd3d8b9f74d4e85e3bae81d3663cc>:0
    7.   at UnityEngine.AddressableAssets.Initialization.InitializationOperation.CreateInitializationOperation (UnityEngine.AddressableAssets.AddressablesImpl aa, System.String playerSettingsLocation, System.String providerSuffix) [0x000d5] in <dfa5fa8b644b4d859b4509577494eb97>:0
    8.   at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync (System.String runtimeDataPath, System.String providerSuffix, System.Boolean autoReleaseHandle) [0x000e8] in <dfa5fa8b644b4d859b4509577494eb97>:0
    9.   at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync () [0x00021] in <dfa5fa8b644b4d859b4509577494eb97>:0
    10.   at UnityEngine.AddressableAssets.AddressablesImpl.get_ChainOperation () [0x00008] in <dfa5fa8b644b4d859b4509577494eb97>:0
    11.   at UnityEngine.AddressableAssets.AddressablesImpl.LoadAssetAsync[TObject] (System.Object key) [0x00008] in <dfa5fa8b644b4d859b4509577494eb97>:0
    12.   at UnityEngine.AddressableAssets.Addressables.LoadAssetAsync[TObject] (System.Object key) [0x00005] in <dfa5fa8b644b4d859b4509577494eb97>:0
    13.   at UnityEngine.AddressableAssets.AssetReference.LoadAssetAsync[TObject] () [0x00006] in <dfa5fa8b644b4d859b4509577494eb97>:0
    14.   at PixelComrades.AssetReferenceEntry`1[T].LoadAsset () [0x00009] in <f77c39fd12ec49b599119dc86a245d1d>:0
    15.   at PixelComrades.AssetReferenceEntry`1[T].LoadAsset (System.Action`1[T] del) [0x00021] in <f77c39fd12ec49b599119dc86a245d1d>:0
    16.  

    this is from when I call
    Code (csharp):
    1.  
    2. AssetReference.LoadAssetAsync<T>().Completed += CompleteLoad;
    3.  
    It is worth noting I am hiding Addressables behind a wrapper class. I've had persistent trouble with Addressables randomly losing its target objects (suddenly its null) so I backup the editor location so I can restore them when that happens but that's only in the editor.

    This is the class
    Code (csharp):
    1.  
    2.  
    3.     [System.Serializable]
    4.     public abstract class AssetReferenceEntry {
    5.         public AssetReference AssetReference;
    6.         public string Path;
    7.         public abstract System.Type Type { get; }
    8.         public abstract UnityEngine.Object Asset { get; }
    9.         public abstract bool IsLoaded { get; }
    10.     }
    11.  
    12.     [System.Serializable]
    13.     public class AssetReferenceEntry<T> : AssetReferenceEntry where T : UnityEngine.Object {
    14.         private bool _isLoaded = false;
    15.  
    16.         private T _loadedAsset;
    17.         private List<Action<T>> _dels = new List<Action<T>>();
    18.         public override Type Type { get { return typeof(T); } }
    19.  
    20. #if UNITY_EDITOR
    21.         public override UnityEngine.Object Asset { get { return AssetReference.editorAsset; } }
    22. #else
    23.         public override UnityEngine.Object Asset { get { return AssetReference.Asset; } }
    24.  
    25. #endif
    26.         public T LoadedAsset {
    27.             get {
    28. #if UNITY_EDITOR
    29.                 if (!Application.isPlaying) {
    30.                     return AssetReference.editorAsset as T;
    31.                 }
    32. #endif
    33.                 return _loadedAsset;
    34.             }
    35.         }
    36.         public override bool IsLoaded {
    37.             get {
    38. #if UNITY_EDITOR
    39.                 if (!Application.isPlaying) {
    40.                     return true;
    41.                 }
    42. #endif
    43.                 return _isLoaded;
    44.             }
    45.         }
    46.  
    47.         public void LoadAsset() {
    48.             AssetReference.LoadAssetAsync<T>().Completed += CompleteLoad;
    49.         }
    50.  
    51.         public void LoadAsset(Action<T> del) {
    52.             if (IsLoaded) {
    53.                 del(_loadedAsset);
    54.                 return;
    55.             }
    56.             _dels.Add(del);
    57.             LoadAsset();
    58.         }
    59.  
    60.         private void CompleteLoad(AsyncOperationHandle<T> load) {
    61.             _loadedAsset = load.Result;
    62.             if (load.Status == AsyncOperationStatus.Failed) {
    63.                 Debug.LogErrorFormat("Failed Loading {0} {1}", Path, load.OperationException.Message);
    64.                 return;
    65.             }
    66.             if (load.Status == AsyncOperationStatus.None) {
    67.                 Debug.LogErrorFormat("Failed Loading {0} {1}", Path, load.OperationException.Message);
    68.                 return;
    69.             }
    70.             _isLoaded = true;
    71.             for (int i = 0; i < _dels.Count; i++) {
    72.                 _dels[i](_loadedAsset);
    73.             }
    74.             _dels.Clear();
    75.         }
    76.  
    77.         public void ReleaseAsset() {
    78.             if (!_isLoaded) {
    79.                 return;
    80.             }
    81.             AssetReference.ReleaseAsset();
    82.             _loadedAsset = null;
    83.             _dels.Clear();
    84.             _isLoaded = false;
    85.         }
    86.     }
    87.  
    88.     [System.Serializable]
    89.     public class GameObjectReference : AssetReferenceEntry<GameObject> {}
    90.  
    The null reference seems to be buried in the Addressables code so not sure how I'd be affecting it though. I'm guessing I am not properly setting up my Addressables data for builds correctly but I can't see anything wrong.