"Hey! There's a bug that can't load a sprite successfully in "Use Asset Database(faster)" mode. The error happens in Addressables 1.4.0(It didn't happen in v1.3.8 or v1.3.3) Exception: In Case 1 we can load a sprite by Addressables.LoadAssetAsync<Sprite>("Assets/Sprites/cells/u1.png") in all visions; But in Case 2, I try to load a sprite by Addressables.LoadAssetAsync<Sprite>("Assets/Sprites/cells/u1.png") (or by AssetReference.LoadAssetAsync<Sprite> way)in v1.4.0,it throw an exception as above. ps:"Simulate Group" mode and "Use Existing Build " mode can load a sprite properly in v1.4.0. ps:Addressables.LoadAssetAsync<Texture2D>("Assets/Sprites/cells/u1.png") works in v1.4.0. Case 1: Drag PNGs into a group Case 2: Drag a folder contains PNGs
Huh, that is very odd. Thanks for pointing this out. If you haven't already would you mind filing a bug with Unity and posting the case number here?
(Case 1204628) [Bug]Addressable Assets System cann't load a sprite Ha-ha,it's my first time to send a bug report
Still getting this with 1.5.0, any eta on when this maybe fixed? thnx Is there a workaround in the meantime?
Looks like it is the same one as this: https://forum.unity.com/threads/cas...lder-with-label-in-addressables-1-4-0.786908/ Why haven't they fixed it in 1.5.0?? It is actually a very big bug for development workflow and is keeping me on 1.3.8
Not as of yet, sorry. We do have a bug filed for the issue and are trying to get to it and others as quickly as possible.
Our only workaround was to keep people on 1.3.8 and put the external builds ( by changing the manifest at build time ) to 1.6.0
The issue seems to reside in BuildScriptFastMode. When performing GatherAssetsForFolder it doesn't make use of the AddressableAssetEntry.CreateCatalogEntries - which does the job of adding multiple locations (the first of each type of asset found for the guid/file - and all those subobject addresses). This hits sprites, or fbx files etc. A special exception is made for the SpriteAtlas. So a hack/work around for now, is to also include the scenario where a Texture2D is found too. Something like this: Code (CSharp): private void GatherAssetsForFolder(AddressableAssetEntry entry, AddressableAssetsBuildContext aaContext) { var allEntries = new List<AddressableAssetEntry>(); entry.GatherAllAssets(allEntries, false, true, true); foreach (var e in allEntries) { var type = e.MainAssetType; if(type == typeof(SpriteAtlas)) e.CreateCatalogEntries(aaContext.locations, false, typeof(AssetDatabaseProvider).FullName, null, null, aaContext.providerTypes); //### HACK_START else if (type == typeof(Texture2D)) e.CreateCatalogEntries(aaContext.locations, false, typeof(AssetDatabaseProvider).FullName, null, null, aaContext.providerTypes); //### HACK_END else { if (e.IsScene) type = typeof(SceneInstance); aaContext.locations.Add(new ContentCatalogDataEntry(type, e.AssetPath, typeof(AssetDatabaseProvider).FullName, e.CreateKeyList())); } } }
I thought this was a problem only with 1.6.2 because I had been waiting on updating until now and came across the problem, but indeed I just checked and it had to go back to 1.3.8 for it to work correctly.
I've got a high priority bug put in to look at this. I can't make any promises as to when we'll get to it (hopefully soon, I just can't say for sure). Hopefully the workaround posted above will work for anyone running into this problem. I'm sure that's not the news you were hoping for so I apologize for that.
I'm facing a similar issue. Not the exact same repro, since I'm using labels and I'm trying to load sprites as sub-assets from a png. Code (CSharp): Addressables.LoadAssetsAsync<IList<Sprite>>( keys: new string[] { "decor", "sprites" }, callback: this.OnDecorSpriteLoaded, mode: Addressables.MergeMode.Intersection); Spoiler: logged exception Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[UnityEngine.Sprite]]], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=System.String[], Type=System.Collections.Generic.IList`1[UnityEngine.Sprite] UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:<.ctor>b__33_0(AsyncOperationHandle) DelegateList`1:Invoke(AsyncOperationHandle) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.AddressableAssets.Initialization.<>c__DisplayClass13_0:<LoadContentCatalogInternal>b__0(AsyncOperationHandle`1) DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.ResourceManagement.ChainOperation`2:OnWrappedCompleted(AsyncOperationHandle`1) DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/DelegateList.cs:69) UnityEngine.ResourceManagement.ResourceManager:Update(Single) MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.6.0/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:19)
k so the way we worked is to add else if (type == typeof(Texture2D)) e.CreateCatalogEntries(aaContext.locations, false, typeof(AssetDatabaseProvider).FullName, null, null, aaContext.providerTypes); //### HACK_END into BuildFastMode as instructed above and in our AssetManager, we passed in the InternalID from the IResourceLocator if the thing is a sprite, just using an IResourceLocator directly works for every assets but sprites and this finally fixed the issue for us. e.g LoadAssetAsync<Sprite>( obj.InternalID ) thnx
Nope still happens in 1.7.4 but you can workaround it like i did above...embed the addressables package into your project then add the #HACK stuff - you can check this into source control and everyone will get the change.. Then load the sprites via the internalId from the ResourceLocator ( this is just the path in the addressables dialog ) and it works for us...there maybe other workarounds but that will get you going, this runs on 1.6.2
I think I've stumbled upon the same issue. But in my case I'm trying to load ScriptableObject sub-assets by label. There are multiple things broken with this: The catalog itself seems to have no information about sub-asset names. It might have worked (if not for the issue #2) if all sub-assets were of different types (because the system can load different sub-assets from the exact same path in bundle but different object types). But if there are multiple sub-objects of the same type, only the first one can be loaded because it's not possible to distinguish them at run-time. The loading logic is bugged if you try to load for example a ScriptableObject with one sub-object of different type. It will correctly generate a list of 2 IResourceLocation (the same InternalId, different ResourceType), but load the same object twice. This also leads to Addressable Event Viewer crashing. This happens because the load operation for the second asset is not started, it erronously returns the same operation from cache (IResourceLocation Hashing logic doesn't take ResourceType into account). Related to both of the above: build scripts add catalog entries for each sub-object, but only once of each unique type. This leads to issue #2 loading the same object twice. The reason for doing it this way also eludes me. Please fix this. The original issue was reported 4 months ago! PS: worked around this for the moment by calling ResourceManager.ProviderResource<IList<Object>>() for each IResourceLocation that is not a prefab and then calling ResourceManager.CreateGenericGroupOperation. There are special cases for this built into resource providers that return all objects at path if you request an IList<T>. Then I can just flatten the results. Still, some of the above issues needs fixing.
I've resorted to using 1.8.5's BuildScriptFastMode with Addressables 1.16.6 for now. It only needs a minor change to work. In BuildDataImplementation(), there's this code: Code (CSharp): var aaContext = new AddressableAssetsBuildContext { settings = aaSettings, //obsolete runtimeData = new ResourceManagerRuntimeData(), bundleToAssetGroup = null, locations = new List<ContentCatalogDataEntry>(), providerTypes = new HashSet<Type>() }; AddressableAssetsBuildContext.settings is obsolete, so just replace it with the property "Settings": Code (CSharp): var aaContext = new AddressableAssetsBuildContext { Settings = aaSettings, runtimeData = new ResourceManagerRuntimeData(), bundleToAssetGroup = null, locations = new List<ContentCatalogDataEntry>(), providerTypes = new HashSet<Type>() };