using System; using System.Threading; using CommandLine; using Sirenix.OdinInspector; using UnityEngine; using YooAsset; namespace ET { public class Init: MonoBehaviour { private void Start() { DontDestroyOnLoad(gameObject); #if UNITY_EDITOR //Editor模式下去掉debug浮窗插件 var debugObj = GameObject.Find("IngameDebugConsole"); if(debugObj != null) { GameObject.Destroy(debugObj); } #endif AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Log.Error(e.ExceptionObject.ToString()); }; Game.AddSingleton(); // 命令行参数 string[] args = "".Split(" "); Parser.Default.ParseArguments(args) .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}")) .WithParsed(Game.AddSingleton); Game.AddSingleton(); Game.AddSingleton().ILog = new UnityLogger(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); ETTask.ExceptionHandler += Log.Error; Game.AddSingleton().Start(); } private void Update() { Game.Update(); } private void LateUpdate() { Game.LateUpdate(); Game.FrameFinishUpdate(); } private void OnApplicationQuit() { Game.Close(); } } }