- Home /
loading elements on startup
I would like to load some objects when the scene is loading.
Right now i have a global variable: bullets = Array(); On my player Start() method i am instantiating some bullets and adding them to the global array.
What i would like to know is how to do this when the scene starts and not when the player object does.
Is there a way to attach an script to the scene loading/starting? or someway that allows me to make all this instantiaton of objects when the scene initializes.
Thanks in advance,
Pablo
Answer by Brian-Kehrer · Nov 18, 2009 at 06:07 AM
Additionally, instead of instantiating the objects on Start(), consider instantiating them on Awake(), as that is called first, immediately after the scene loads, and before all the Start() calls.
Answer by duhprey · Nov 18, 2009 at 02:14 AM
The way I do this is to instantiate everything (or almost everything) via a script and then create one Empty game object and attach the startup script to that.
Thanks! Then the steps would be: - create empty gameobject - attach script to it which on start instantiates my other objects. That way i can later also access the objects which are child of that "game manager" gameobject, can i?
Yes, you can save them there for later. I'm fond of using GameObject.FindGameObjectsWithTag because you can use it anywhere and it helps you organize the objects.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Instantiate GUI text 1 Answer
Terrain with lots of objects 1 Answer
cannon script is not working, no errors. 1 Answer
object count cap? 1 Answer