Best way to add setup prefab with dependency to other prefab instance
Hi,
Let's say I have a different gun prefabs like RailGun
, LaserGun
, etc.
Each of those prefabs shoot projectiles like LaserProjectile
, RailProjectile
, which depend on correct projectile pool prefab to store a pool of 10 pre-Instantiated projectiles.
So I have LaserProjectilePool
which holds LaserProjectile
etc.
So right now I do something like this:
Add
LaserGun
prefab to the scene and make it child of aPlayer
objectAdd
LaserProjectilePool
to the scene globally (unrelated toPlayer
) objectLink
LaserProjectilePool
toLaserGun
in the scene ... and I do it for each type of gun / pool. Also I have different kinds of pools for explosions likeLaserExplosionPool
and so on.
What's the best/automatic way to ensure I have both of those and linked automatically in the scene, without too much coding?
What comes to my mind:
add OnEnable logic which Instantiates the pool if it doesn't exist
add a custom editor button "Create Pool if Doesn't exist" for prefab with dependency
add a custom editor button "Find All Guns and Assign Pool"
use some plugin like
PrefabInstance
?
Your answer
Follow this Question
Related Questions
Problem with different behaviors as a prefab vs. the original gameobject. Thoughts? 0 Answers
PrefabUtility.RevertPrefabInstance() not working 2 Answers
How to safely delete a prefab? 0 Answers
The prefabs stop instantiating after some time. 1 Answer
Problem renaming prefab instance in scene (from custom editor window) 1 Answer