Hi. Is there a way to be notified when a new GameObject gets instantiated?
Is there a global event for this maybe?
Hi. Is there a way to be notified when a new GameObject gets instantiated?
Is there a global event for this maybe?
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.