- Home /
Where do I add code to do procedural generation of environments?
Say for example I want to generate an asteroid field with varying sizes of a single asteroid model. Where would i add this so that it only runs one time at run time? I know how to add components to things in the scene but not to the scene itself. Thoughts?
Answer by DavidDebnar · Jul 11, 2013 at 10:22 AM
What people usually do, is they create a 'Manager' empty game object, that has scripts like this one. As for running it once, you can use Start or Awake.
--David--
Thank you! That helps. Seems a bit hacky, but i think it will work.
It's not hacky, it's the only way to do it :P. The closest you can get to 'adding a component to the scene itself' would be static classes, but those are abstract and can't derive from $$anonymous$$onoBehaviour, hence can't use neither Start nor Awake, so you'd have to call them from the $$anonymous$$anager gameObject anyways.