using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using TMPro; using UnityEngine; [assembly: InternalsVisibleTo("TFramework.Editor")] namespace TFramework { [DefaultExecutionOrder(-10000)] [AddComponentMenu("TFramework/全局管理(Main)")] [DisallowMultipleComponent] public class Main : SingletonBehaviourBase
{ [SerializeField] internal List m_ManagerList = new List(); //public bool IsEnableDebug; /// /// 供非Mono脚本使用Update事件 /// public TAction onUpdate; protected override void Awake() { base.Awake(); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { onUpdate?.Invoke(); } /// /// 获取指定类型管理器 /// /// 管理器类型 /// 管理器 public static T GetMagr()where T:MonoBehaviour { T magr = Instance?.m_ManagerList.Find(p => p.GetType() == typeof(T)) as T; if (magr == null) Log.Error($"管理器{typeof(T).Name}未注册"); return magr; } /// /// 延时执行 /// /// 延时时间 /// 执行事件 public Coroutine Delay(float time, TAction action) => StartCoroutine(DelayAction(time, action)); /// /// 延时执行 /// /// /// /// private IEnumerator DelayAction(float time, TAction action) { yield return new WaitForSeconds(time); action?.Invoke(); } } public delegate void TAction(); public delegate void TAction(T arg0); public delegate void TAction(T1 arg0, T2 arg1); public delegate void TAction(T1 arg0, T2 arg1, T3 arg2); public delegate TRes TFunc(); public delegate TRes TFunc(T1 arg0); public delegate TRes TFunc(T1 arg0, T2 arg1); public enum ResLoadMode { Resourece, AssetBundle } public enum UpdateMode { Editor, Loacl, Bulid } }