I’m writing a network handler that I want to be able to drop into a scene and with a few clicks get my objects synced across the network. The only piece of the puzzle I am missing is some way to listen for when a new object is added to the scene. Is there any way to do this?
@BFips, do you want to listen instantiating objects of target type or every gameObject in scene?
Solution for target type is:
public class Item : MonoBehaviour {
public static event Action<Item> onInstantiated;
private void Awake() {
onInstantiated(this);
}
}
So you can use static event Item.onInstantiated to subscribe or unsubscribe.