- Home /
Using ScriptableObjects data loaded with the Addressable Package
Hi,
I am currently making some tests to load ScriptableObjects using the Addressable Package from Unity.
Loading the ScriptableObject works fine but I can't figure out what happens when I want to use data from that ScriptableObject in my scene.
Here is my typical scenario :
I have a ScriptableObject only containing one sprite,
I load that ScriptableObject using Addressables.LoadAsset (that will load the sprite as well, as it's considered a dependency of that ScriptableObject),
I take the sprite from the LoadAsset result (= the loaded ScriptableObject) and apply it in a UI Image Component of a canvas already existing in the scene,
I then unload the ScriptableObject but the sprite is still there, displayed in my Image Component.
Shouldn't the sprite be destroyed as I unload the SO ?
As the sprite is only assigned to a image component and not added to the scene using the Addressable Package's Instantiate method I don't know what happens.
If anyone uses the Addressable Package to load SOs that hold data for other GameObjects, I would love to hear from you ! Thanks guys.
Just use the scritableObject as a data container with a little some helper method, do not overuse of it .
Haven't worked with ScriptableObjects and Addressable packages, but my guess would be that the image stays because your UI has a reference to it. No idea if the Unload method is supposed to erase it from the memory and thus break the things on your UI, but that's the only thing I can think of.
Might be that you just have to handle it manually and every time you unload a ScriptableObject you also need to clear out the Image on the UI maybe ?