using System; 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()); }; // 命令行参数 string[] args = "".Split(" "); Parser.Default.ParseArguments(args) .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}")) .WithParsed(World.Instance.AddSingleton); Options.Instance.StartConfig = $"StartConfig/Localhost"; World.Instance.AddSingleton().ILog = new UnityLogger(); ETTask.ExceptionHandler += Log.Error; World.Instance.AddSingleton().Start(); } private void Update() { FiberManager.Instance.Update(); } private void LateUpdate() { FiberManager.Instance.LateUpdate(); } private void OnApplicationQuit() { World.Instance.Dispose(); } } }