| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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<MainThreadSynchronizationContext>();
- // 命令行参数
- string[] args = "".Split(" ");
- Parser.Default.ParseArguments<Options>(args)
- .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
- .WithParsed(Game.AddSingleton);
- Options.Instance.StartConfig = "StartConfig/LockStep";
-
- Game.AddSingleton<TimeInfo>();
- Game.AddSingleton<Logger>().ILog = new UnityLogger();
- Game.AddSingleton<ObjectPool>();
- Game.AddSingleton<IdGenerater>();
- Game.AddSingleton<EventSystem>();
- Game.AddSingleton<TimerComponent>();
- Game.AddSingleton<CoroutineLockComponent>();
-
- ETTask.ExceptionHandler += Log.Error;
- Game.AddSingleton<CodeLoader>().Start();
- }
- private void Update()
- {
- Game.Update();
- }
- private void LateUpdate()
- {
- Game.LateUpdate();
- Game.FrameFinishUpdate();
- }
- private void OnApplicationQuit()
- {
- Game.Close();
- }
- }
- }
|