Hi!
I ask myself if there is any event called, when a prefab is instantiated, so i can call a function.
best,
Andre
Hi!
I ask myself if there is any event called, when a prefab is instantiated, so i can call a function.
best,
Andre
When you instantiate a prefab the awake and start function are called.
For example if you put this on your prefab :
using UnityEngine;
using System.Collections;
public class Hello : MonoBehaviour {
void Awake () {
Debug.print("Awake");
}
void Start () {
Debug.print("Start");
}
}
In the console you will see :
Awake
Start
In the case you want to set a parameter from the spawner to the spawned object you could use SendMessage like this :
void Spawn () {
Transform target = Instantiate(prefab, transform.position, Quaternion.identity) as Transform;
target.SendMessage("Initialisation" /*, your param*/);
}