- Home /
Scriptable Object references to prefabs memory load?
Hi there,
On previous projects, i had a "Factory" prefab, holding a dictionary of ID vs Prefab, in order to instantiate all the tiles of my game. The server simply sent an array of ids, and the level was generated instantiating every prefab matching the id in the dictionary.
That showed to be a bad approach, because whenever the Factory was instantiated, all of the referenced prefabs where loaded in memory aswell. That's why we changed the dictionary to be a ID vs String of paths , but it was quite hard to mantain, because we had to be very careful when typing the paths, and we had to move every single prefab to the resources folder.
My question is: If we store the dictionary in a scriptableobject, referencing all the prefabs, will happen the same as if it was a prefab? Will all of the referenced prefabs be loaded in memory whenever we access the scriptableobject?
Thanks! Oakshiro
Was AssetDatabase.GetAssetPath(ID) not working for you when maintaining path strings? (called in OnValidate method somewhere).
As far as I know Scriptableobject shares some implementation/behaviour details with $$anonymous$$onobehaviour. I never profiled that specifically but I believe that yes - this is the case that all referenced objects will be loaded when Scriptableobject itself is loaded.
Answer by oakshiro · Jul 26, 2017 at 09:53 AM
I found the answer here http://answers.unity3d.com/questions/1249485/scriptable-object-references-to-prefabs.html
Your answer
Follow this Question
Related Questions
MonoBehavior, ScriptableObject and Object memory usage & performance 0 Answers
Memory usage of Sprites in a referenced Scriptable Object 0 Answers
Scriptable Objects or Scenes ,Dungeon game: Use scens or Scriptable object? 0 Answers
Loop through a List to check whether a bool is true within a ScriptableObject 1 Answer
Why is play mode reverting my scriptableobject to a previous serialized state? 2 Answers