I have found an interesting bug, I cannot continue on my project due to this bug.
I’m using Addressable in my project and everything works fine on the Editor with “Fast Mode”, but if I switch it to “Packed Play Mode”, none of the addressable loads and they stuck at 33%. I made a class to handle load/release process automatically. I thought, maybe it’s about the class but if I create a new project and copy the class to the new project, everything works. So, it doesn’t related to the class.
Here’s the simplified code of the class. I don’t use Coroutines. I use the Completed handlers.
Here’s the debug message. Even if I use Coroutines, it never works because IsDone will never be true.
I tried to clean everything and building the player content, but no luck. Something happened to the project I assume, and I cannot move my entire project to a new project. I’m already at the end.
I think, I found the problem. The problem is Unity has a cache somewhere that uses for gameobject, components etc.
The problem is the references. If I change/add some assets, Unity doesn’t recognize the changes even though I build the Addressables. I need to give more information about my class to make it more clear. In my class, I save AssetReferences in arrays and set the arrays in the editor. The code is like this:
[SerializeField] private AssetReference[] Characters = null;
[SerializeField] private AssetReference[] Sounds = null;
[SerializeField] private AssetReference[] Weapons = null;
//... And many same type of arrays
In the code, I merge them into a dictionary with specific keys (string values). The keys are set in the editor as well. The keys are like IDs. The class logic is basically like this: when I need to load something, I pass a key to a function, and it loads and returns the related asset for me.
Here’s how I solved the problem, but this solution is very time consuming and doesn’t make any sense at all.
I created a new class and copied the same code to the new class, so no logic changed in the code. When I set the AssetReference arrays in the new class, Addressable started working with the new class. The old class still doesn’t work. There is literally no difference between the two classes. I just only set the AssetReferences arrays again. I guess, there is a cache or something in Unity that prevents Addressable from working in “Packed Play Mode”. In “Fast Mode”, both classes work.
The new question is how can I remove/delete that cache. The cache is NOT related to Addressable. It is related to the AssetReferences arrays, which is a gameobject’s script. Because if I need to add new Addressable objects in the project, I need to add a new element to the arrays. If Unity starts doing this again, I need to create a new class and set the arrays again. There are ~700 assets in the project.
I need a quick solution for this problem in case I come across this problem again. I’m now scared of using Unity if it does the same thing.