using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; /// /// Mono的管理者 /// 1.声明周期函数 /// 2.事件 /// 3.协程 /// public class MonoController : MonoBehaviour { private event UnityAction updateEvent; // Use this for initialization void Start () { DontDestroyOnLoad(this.gameObject); } // Update is called once per frame void Update () { if (updateEvent != null) updateEvent(); } /// /// 给外部提供的 添加帧更新事件的函数 /// /// public void AddUpdateListener(UnityAction fun) { updateEvent += fun; } /// /// 提供给外部 用于移除帧更新事件函数 /// /// public void RemoveUpdateListener(UnityAction fun) { updateEvent -= fun; } }