IEnumerator Start() { DontDestroyOnLoad(gameObject); #region Modules StateMG = GameModuleProxy.GetModule <GameStateManager>(); EventMG = GameModuleProxy.GetModule <EventManager>(); ResourceMG = GameModuleProxy.GetModule <ResourceManager>(); HotfixMG = GameModuleProxy.GetModule <HotfixManager>(); WebRequestMG = GameModuleProxy.GetModule <WebRequestManager>(); UIMG = GameModuleProxy.GetModule <UIManager>(); #endregion #region Hotfix //是否使用热更的方式加载代码 HotfixMG.UseHotFix = UseHotFix; #endregion #region Resource ResourceMG.LocalPathType = LocalPathType; ResourceMG.ResUpdateType = ResUpdateType; ResourceMG.ResUpdatePath = ResUpdatePath; //添加对象池管理器 GameObject GameObjectPoolHelper = new GameObject("IGameObjectPoolHelper"); GameObjectPoolHelper.transform.SetParent(transform); ResourceMG.SetGameObjectPoolHelper(GameObjectPoolHelper.AddComponent <GameObjectPoolHelper>()); #endregion #region WebRequest GameObject webRequestHelper = new GameObject("IWebRequestHelper"); webRequestHelper.transform.SetParent(transform); GameObject webDownloadMonoHelper = new GameObject("IWebDownloadHelper"); webDownloadMonoHelper.transform.SetParent(transform); WebRequestMG.SetWebRequestHelper(webRequestHelper.AddComponent <WebRequestMonoHelper>()); WebRequestMG.SetWebDownloadHelper(webDownloadMonoHelper.AddComponent <WebDownloadMonoHelper>()); #endregion #region GameState 初始化状态,开启整个流程 Assembly = typeof(GameMain).Assembly; StateMG.CreateStateContext(Assembly); yield return(new WaitForEndOfFrame()); StateMG.StartFirstState(); #endregion }