using System; using Cysharp.Threading.Tasks; using UnityEngine; using YooAsset; using ZC; namespace Unity.Loader { public class Global : MonoBehaviour { private InitializePackage _initializePackage; [SerializeField] EPlayMode playMode; [SerializeField] private string packageName = "DefaultPackage"; ZCGame zcGame; private float time; private GlobalData _globalData; public GlobalData Data => _globalData; // Action public static Action updateTime; public static Action updateScore; public static Action updateProgress; private Transform _objectPool; private bool isDisposed; private bool isPause; private float gameTime; public static Global _global; private ObjectManager _objectManager; private UIManager _uiManager; private ProcedureManager _procedureManager; private ResourcesLocalComponent _resourcesLocalComponent; public static Transform ObjectPool => _global._objectPool; public static float GameTime => _global.gameTime; public static IObjectManager ObjectManager => _global._objectManager; public static IUIManager UIManager => _global._uiManager; public static IProcedureManager ProcedureManager => _global._procedureManager; public static IResourcesLocalComponent ResourcesLocalComponent => _global._resourcesLocalComponent; private void Awake() { _global = this; DontDestroyOnLoad(this.gameObject); } private void Start() { this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback); _globalData = new GlobalData(); } private void Update() { time += Time.fixedTime; updateTime?.Invoke(_globalData.runTimeStr); // Debug.Log($"{_globalData.runTimeStr}"); } private void OnDestroy() { _globalData.Dispose(); } private void FinishCallback() { // yoo init finish Debug.Log($"yoo init finish {DateTime.Now}"); this._objectPool = transform.Find("ObjectPool"); this.isDisposed = false; this.isPause = false; AssemblyManager.Initialize(); } } }