0
\$\begingroup\$

If I create a prefab out of an object on scene will my game take more memory in Unity?

I have 30 enemies on my scene. I created a prefab for every one of them. I am going to use each of the created prefabs to respawn enemies in the same places where I put each one of them, with the same configurations.

Now, my question is if it is ok to create a lot of prefabs? Will Unity know how to prevent them taking a lot of space? Or will I have troubles with memory when I will create more levels (read here scenes) with even greater amount of enemies, given that each enemy will have its own prefab?

\$\endgroup\$
1
  • \$\begingroup\$ This looks like a question you can answer for yourself by generating a build without prefabs, then generating a build with prefabs, and comparing their memory use. What have the results of this experiment been when you've tried it? Have you measured any meaningful difference at all? \$\endgroup\$
    – DMGregory
    Jun 16 at 22:22
2
\$\begingroup\$

.PREFAB files are just text files taking very little space. Prefabs are just saved information of how the game object should be configured or what components should be attached at the time of instantiation into the scene. So, creating lots of prefabs can consume very little memory or disk space only in the editor mode. But in the final build, there is no effect of creating lots of prefabs.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.