using System; using System.Threading; using CommandLine; using UnityEngine; namespace ET { public class Init: MonoBehaviour { private void Start() { DontDestroyOnLoad(gameObject); 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(); } } }