1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System.Threading;
- using UnityEngine;
- using UnityEngine.Events;
- namespace WS
- {
-
- public abstract class Init : MonoBehaviour
- {
- private void Awake()
- {
-
- SynchronizationContext.SetSynchronizationContext(
- OneThreadSynchronizationContext.Instance
- );
-
- Application.targetFrameRate = 90;
- #if UNITY_EDITOR
- Log.IsEditor();
- #endif
- #if DEBUG_MODEL
- Log.IsDebug();
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Reporter/Reporter"));
- #endif
- #if DEBUG_LOG
- Log.IsWrite();
- #endif
-
- DontDestroyOnLoad(gameObject);
-
- Game.Init = this.transform;
-
- Game.EventSystem.LoadSystem(typeof(Init).Assembly);
-
- Game.Scene.AddComponent<TimerComponent>();
-
- Game.Scene.AddComponent<VoiceManager>();
-
- Game.Scene.AddComponent<GamePoolManager>();
-
- Game.Scene.AddComponent<FacadeComponent>();
-
- Game.Scene.AddComponent<SceneComponent>();
-
- Game.Scene.AddComponent<RequestComponent>();
-
- Game.Scene.AddComponent<EventComponent>();
- }
- private void Start()
- {
-
- Initialize();
- }
-
- public abstract void Initialize();
-
- public virtual void OnUpdate() { }
-
- public void Quit(UnityAction OnCallback = null)
- {
- OnCallback?.Invoke();
- #if UNITY_EDITOR
- UnityEditor.EditorApplication.isPlaying = false;
- #else
- Application.Quit();
- #endif
- }
- private void Update()
- {
- OneThreadSynchronizationContext.Instance.Update();
- Game.EventSystem.Update();
- OnUpdate();
- }
- private void FixedUpdate()
- {
- Game.EventSystem.FixedUpdate();
- }
- private void LateUpdate()
- {
- Game.EventSystem.LateUpdate();
- }
- }
- }
|