public class AAA: MonoBehaviour { public delegate void PlayEndDelegate(); public event PlayEndDelegate playEndEvent; private void playEndHandler(){ playEndEvent(); } }
public class BBB: MonoBehaviour { public AAA aaa; void Start () { aaa.playEndEvent+=playEndHandler; } private void playEndHandler(){ Debug.Log("bbb playEndHandler"); } } //output: bbb playEndHandler
时间: 2024-10-15 01:24:00