- Home /
 
               Question by 
               VSZM · Jan 20, 2015 at 10:36 PM · 
                gameobjectinstantiateevent  
              
 
              How to be notified of new GamObject creation?
Hi. Is there a way to be notified when a new GameObject gets instantiated?
Is there a global event for this maybe?
               Comment
              
 
               
              Answer by skylem · Jan 21, 2015 at 12:13 AM
There are a couple of ways to acheive this but in answer to your question no i don't think unity has a pre-existing method to do so Below is an example of using an instantiation to fire a function to message the Debug menu.
     GameObject curSpawn;
     GameObject spawn;
     bool noNotice;
     
     
     void Start() {
       GameObject sp = GameObject.Instantiate (spawn, transform.position, transform.rotation);
     curSpawn = sp;
     noNotice = true;
     }
     
     void Update(){
        if(noNotice && curSpawn != null) {
              GetNotice();
     }
     }
     void GetNotice() {
            Debug.Log(curSpawn.name + " has been spawned");
     }
 
let me know if this helps you, if not i'll make some changes.
Your answer
 
 
             Follow this Question
Related Questions
Instantiated Objects not being set at ground/terrain level?(Solved) 1 Answer
Unwanted 2nd empty gameobject 1 Answer
Every NetworkViewID is 0? 0 Answers
NavMesh giving jerky like motion 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                