Loading them works fine in playmode, but as soon as i build (to android), they just won’t load.
I’ve found the Addressable Assets management window, where i changed the “playmode script” to “Packed Play Mode”, tried to build the assets (Build => Build Player Content), but this just results in an argumentException error message reading “An item with the same key has already been added. …”
Full error message: https://pastebin.com/YVNppkdi
How can i fix this?
EDIT:
I’ve also tried to build it for windows, to see if it was an android related issue. It does not work on a windows build either.
The full path of the .jpgs does not exceed 255 characters. Regarding windows MAX_PATH issue.
So, i closed unity (because it was frozen… again), deleted all the 15.000 icons, opened unity again and put one single icon in to test. The bundle COMPILED!
Then i went up to 20 icons. It compiled!
Next step, 1500 icons. It compiled again.
Then i went ahead and put in all the 15000 icons back in again. And… it compiled…? Wtf
First off, somehow my 60mb worth of icons compressed down to 330mb? wtf unity?
Next i built the project to my phone aaaaad it works! Really happy!
Honestly, this is just bad design from unity.
It will work in the editor with no problems, but to get it to work in Build, you have to navigate to (in the top bar) Window → Asset Management → Addressables → (new windows top bar) Build → Build Player Content
This is where i got the exception that seemed to disappear after manually re-importing everything.
If you don’t build the addressables, they won’t be included in the build, hence you get a lot of InvalidKeyExceptions, because the assets corresponding to the keys are not present in the build.
Unity could at least pop a little message box when building “oi, m8 watch out you haven’t built your player content” but it builds without a warning.
Yes, for every change you make to the addressable assets, you have to build the player content again
Deleted AddressableAssetsData folder and recreated it - it fixed building of asset bundles.
But new problem now - loading of assets doesn’t work if selected Play Mode script - Use Existing Build (requires build groups). Every load request stops on PercentComplete = 0.5 and IsDone = false. I’ve tried many options - Local Build Path and Local Load Path, Remote and Remote and so on - the same result. Is it known issue?
UPD: Just tested - loading assets doesn’t work in build too. No errors, just stuck on load.
It’s not a bad design if you know what has to be done to make this work.
the addressable asset system uses asset bundles. Basically putting assets into bundles and compressing them.
Bundles aren’t made magically and people with large projects don’t want addressable building to be forced when making a new player build. Hence this has to be done manually using the menu. However, if you still want it to be automatically built upon building the player you can make a simple pre-processing build script using the IPreProcessingBuildWithReport interface. https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.html
For me I have a custom build tool which I can specify whether I’d want to clean the addressables and rebuild them or just incrementally build them. All you have to do is call the right API.
So I’m quite glad it isn’t forced upon building the player, if I really want to build the addressables I want to be in control of that rather than Unity. Why not make it a setting then? you’d probably ask. Well if someone else in source control turns it on and someone else wants it off but doesn’t notice that before building they’d be sitting there building the addressables which could take hours for that person. It’s a setting that is hidden somewhere in the addressables settings which does something to your build process. imho none should want that. Hence if you really want it you should build a tool yourself that does this for you. It’s all about control and where you put that control.
Are you referencing the assets through public AssetReference fields in your script or are you loading them using a string key?
Posting some code would be useful together with a small screenshot of your addressable setup & bundle settings of what you’re trying to load.
It should not build automaticly for every build. It shouldn’t be a setting either.
But it for sure should pop a little Debug.LogWarning if you build without any compiled player content at all! Maybe make that an option to turn off the LogWarning! What would be the downsides of that?
Though in my case the unity was not frozen but still the windows build was not able to load assets. It was loading a night ago but suddenly stopped loading. Then after reading your message, I restarted unity and rebuilt the app and it started working! So it was nothing related to server setting or addressable settings but something related to unity purely. Thanks for sharing your experience.