[ad_1]
Game Development Stack Exchange is a query and reply website for skilled and unbiased sport builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The finest solutions are voted up and rise to the highest
Asked
Viewed
156 occasions
If I create a prefab out of an object on scene will my sport take extra reminiscence in Unity?
I’ve 30 enemies on my scene. I created a prefab for each one among them. I’m going to make use of every of the created prefabs to respawn enemies in the identical locations the place I put every one among them, with the identical configurations.
Now, my query is whether it is okay to create a variety of prefabs? Will Unity know how one can forestall them taking a variety of house? Or will I’ve troubles with reminiscence when I’ll create extra ranges (learn right here scenes) with even higher quantity of enemies, given that every enemy could have its personal prefab?
$endgroup$
1
.PREFAB recordsdata are simply textual content recordsdata taking little or no house. Prefabs are simply saved data of how the sport object needs to be configured or what elements needs to be connected on the time of instantiation into the scene. So, creating numerous prefabs can eat little or no reminiscence or disk house solely within the editor mode. But within the remaining construct, there isn’t any impact of making numerous prefabs.
$endgroup$
It is dependent upon how you employ them, however usually prefabs will take reminiscence within the sport (not simply within the editor), even when you don’t instantiate them.
More concretely, any prefab that’s referenced by a loaded scene might be loaded to reminiscence as properly.
You can keep away from this by not referencing your prefab instantly, and as an alternative put it within the Resources folder and instantiating it by calling Resources.Load.
This approach, the reminiscence might be used solely whenever you want the prefab, and never when the scene hundreds, which could have a huge effect should you use numerous prefabs (or giant prefabs).
$endgroup$
1
You should log in to reply this query.
lang-cs
[ad_2]