using System; using System.Threading; using KYFramework; using UnityEngine; using Logger = KYFramework.Logger; namespace VRPlatform { public class Init : MonoBehaviour { private void Awake() { try { SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance); DontDestroyOnLoad(gameObject); Game.EventSystem.Add(typeof(Init).Assembly); Game.EventSystem.Add(typeof(Entity).Assembly); #if UNITY_EDITOR Logger.Instance.ILog = new ULogger(); #else Logger.Instance.ILog = new NLogger("Client", "NLog/NLog.config"); #endif Game.EventSystem.Publish(new StartApp()); } catch (Exception e) { Debug.Log(e); } } private void Update() { OneThreadSynchronizationContext.Instance.Update(); Game.EventSystem.Update(); } private void LateUpdate() { Game.EventSystem.LateUpdate(); } private void OnApplicationQuit() { Game.Close(); } } }