O
O
Oleg Safin2020-11-10 11:38:54
Unity
Oleg Safin, 2020-11-10 11:38:54

Prefabs with MonoBehaviour in Unity share common graphical resources or do I need to use ScriptableObject?

Let's say I have an Enemy prefab , it has a SpriteRenderer component with a sprite assigned. If you instantiate 100 such prefabs, will the SpriteRenderer components refer to 1 sprite in memory, or will each be allocated its own area in memory?

Or, in order to save resources, you need to use ScriptableObject and assign a sprite from SO when initializing the prefab?

The question is where is the best place to store a reference to a sprite for objects that can potentially number in the hundreds - in the MB of the prefab or SO, the reference to which will be in the MB of the prefab

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-11-10
@Ldfa

Wherever you store links, the problem is that once that object is the link store, all those sprites will also be loaded into memory, even if none of them are shown. It is better to load such sprites from resources.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question