コード例 #1
0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(typeof(Init).Assembly);

                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #2
0
        private async ETVoid StartAsync()
        {
            try
            {
                Log.Debug(PathHelper.AppHotfixResPath);
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);
                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);
                Game.Scene.AddComponent <TimerComponent>();               //计时器
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();             //
                Game.Scene.AddComponent <UIComponent>();               //UI
                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();
                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();
                Game.Hotfix.GotoHotfix();
                Game.EventSystem.Run <string>(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #3
0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <UnitComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #4
0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                ClientConfigHelper.SetConfigHelper();
                Game.EventSystem.Add(DLLType.Core, typeof(Core).Assembly);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                ETModel.Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                UnitConfig unitConfig = (UnitConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(UnitConfig), 1001);
                Log.Debug($"config {JsonHelper.ToJson(unitConfig)}");


                //添加指定与网络组件
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();

                ////添加UI组件
                Game.Scene.AddComponent <UIComponent>();

                Game.Scene.AddComponent <GamerComponent>();

                //加上消息分发组件MessageDispatcherComponent
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                //执行斗地主初始事件,也就是创建LandLogin界面
                Game.EventSystem.Run(UIEventType.LandInitSceneStart);



                ////练习3
                //TestRoom room = ComponentFactory.Create<TestRoom>();
                //room.AddComponent<TimeTestComponent>();
                //room.GetComponent<TimeTestComponent>().Run(Typebehavior.Waiting, 5000);

                //测试发送给服务端一条文本消息
                Session         session        = Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);
                G2C_TestMessage g2CTestMessage = (G2C_TestMessage)await session.Call(new C2G_TestMessage()
                {
                    Info = "==>>服务端的朋友,你好!收到请回答"
                });
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #5
0
ファイル: Init.cs プロジェクト: gucongyi/MyHot
/*#if UNITY_ANDROID
 *      private int scaleWidth = 0;
 *      private int scaleHeight = 0;
 *      public void setDesignContentScale()
 *      {
 *          if (scaleWidth == 0 && scaleHeight == 0)
 *          {
 *              int width = Screen.currentResolution.width;
 *              int height = Screen.currentResolution.height;
 *              int designWidth = 1136;
 *              int designHeight = 640;
 *              float s1 = (float)designWidth / (float)designHeight;
 *              float s2 = (float)width / (float)height;
 *              if (s1 < s2)
 *              {
 *                  designWidth = (int)Mathf.FloorToInt(designHeight * s2);
 *              }
 *              else if (s1 > s2)
 *              {
 *                  designHeight = (int)Mathf.FloorToInt(designWidth / s2);
 *              }
 *              float contentScale = (float)designWidth / (float)width;
 *              if (contentScale < 1.0f)
 *              {
 *                  scaleWidth = designWidth;
 *                  scaleHeight = designHeight;
 *              }
 *          }
 *          if (scaleWidth > 0 && scaleHeight > 0)
 *          {
 *              if (scaleWidth % 2 == 0)
 *              {
 *                  scaleWidth += 1;
 *              }
 *              else
 *              {
 *                  scaleWidth -= 1;
 *              }
 *              Screen.SetResolution(scaleWidth, scaleHeight, true);
 *          }
 *      }
 *
 *      void OnApplicationPause(bool paused)
 *      {
 *          if (paused)
 *          {
 *          }
 *          else
 *          {
 *              setDesignContentScale();
 *          }
 *      }
 #endif*/
        private async void Start()
        {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
            //禁用多点触控
            Input.multiTouchEnabled                    = false;
            Application.targetFrameRate                = TargetFrameRate;
            ETModel.Define.IsABNotFromServer           = isABNotFromServer;
            ETModel.Define.SelfResourceServerIpAndPort = selfResourceServerIpAndPort;
            ETModel.Define.isShowFPS                   = isShowFPS;
            ETModel.Define.versionGameCode             = versionGameCode;
            ETModel.Define.GameShowVersion             = GameShowVersion;
            ETModel.Define.isInnetNet                  = isInnetNet;
            try
            {
                //播放背景音乐
                GameSoundPlayer.Instance.PlayBgMusic("ExampleBgMusic");
                Define.isUseAssetBundle = isUseAssetBundle;
                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <UIComponent>();
                Game.Scene.AddComponent <BundleDownloaderComponent>();
                Game.EventSystem.Run(EventIdType.LoadingBegin);//打开进度条,最外层的
                var IsGameVersionCodeEqual = await BundleHelper.IsGameVersionCodeEqual();

                if (!IsGameVersionCodeEqual)
                {
                    return;
                }
                // 下载ab包
                await BundleHelper.DownloadBundle();

                //await TestWifiUi();
                Game.Scene.RemoveComponent <BundleDownloaderComponent>();
                //解析abmapping
                ABManager.Init();
                //下载好了,声音ab绑定到固定的地方
                await ResetSoundPlayers();

                await UniTask.DelayFrame(1);

                Game.Hotfix.LoadHotfixAssembly();
                // 加载配置
                await Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("config.unity3d");

                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                Game.Hotfix.GotoHotfix();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #6
0
ファイル: Init.cs プロジェクト: fynbntl/NjmjNew
        private async void Start()
        {
            try
            {
                if (Application.unityVersion != "2017.1.3p2")
                {
                    Log.Warning($"请使用Unity2017.1.3p2, 下载地址:\n https://beta.unity3d.com/download/744dab055778/UnityDownloadAssistant-2017.1.3p2.exe?_ga=2.42497696.443074145.1521714954-1119432033.1499739574");
                }

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Application.targetFrameRate = 45;
                // 永不息屏
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
                // 禁止多点触摸
                Input.multiTouchEnabled = false;

                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <BehaviorTreeComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();
                Game.Scene.AddComponent <SessionComponent>();

                //新增Component
                Game.Scene.AddComponent <SoundComponent>();
                // 获取网络配置表
                await NetConfig.getInstance().Req("http://fwdown.hy51v.com/njmj/online/files/netconfig.json");

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #7
0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                #region                                              ///20190620
                Game.Scene.AddComponent <CameraComponent>();         //创建相机组件CameraComponent
                Game.Scene.AddComponent <NumericWatcherComponent>(); //创建数值组件NumericWatcherComponent



                #endregion

                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <UIComponent>();

                #region ///20190613
                Game.Scene.AddComponent <MonsterComponent>();
                Game.Scene.AddComponent <MonsterUnitComponent>();
                Game.Scene.AddComponent <TestComponent>();



                #endregion


                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #8
0
        private async ETVoid StartAsync()
        {
            try
            {
                //给Socket线程队列同步用的
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);

                //反射当前所有的dll
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);


                Game.Scene.AddComponent <TimerComponent>();

                //全局配置文件(服务器的链接IP  资源服务器的HTTP地址)
                Game.Scene.AddComponent <GlobalConfigComponent>();
                //网络组件,进行服务器通讯的额组件
                Game.Scene.AddComponent <NetOuterComponent>();
                //资源管理组件(AB包)
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                //单元组件(熊猫用来做帧同步  Demo用)
                Game.Scene.AddComponent <UnitComponent>();
                //ET的UI框架
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                //读取热更代码(调用ILRuntime)
                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                //消息识别码组件
                Game.Scene.AddComponent <OpcodeTypeComponent>();

                //消息分发组件
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                Game.Hotfix.GotoHotfix();

                //测试代码   可以删
                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #9
0
ファイル: Init.cs プロジェクト: yhr28/ET-Modules
        private async void Start()
        {
            try
            {
                if (Application.unityVersion != "2017.1.3p2")
                {
                    Log.Warning($"请使用Unity2017.1.3p2, 下载地址:\n https://beta.unity3d.com/download/744dab055778/UnityDownloadAssistant-2017.1.3p2.exe?_ga=2.42497696.443074145.1521714954-1119432033.1499739574");
                }

                SynchronizationContext.SetSynchronizationContext(this.contex);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                //Game.Scene.AddComponent<UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();



                //加载行为树
                Log.Debug("开始加载行为树");
                Game.Scene.AddComponent <BeahaviacComponent>();

                //新Ui
                Log.Debug("加载UI框架");
                Game.Scene.AddComponent <UIManagerComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #10
0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);
                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <UIComponent>();

                Game.Scene.AddComponent <ResGroupLoadComponent>();
                Game.Scene.AddComponent <MobileSdkComponent>();
                Game.Scene.AddComponent <CarouseComponent>();
                Game.Scene.AddComponent <TaskManagerComponent>();
                Game.Scene.AddComponent <ClickEffectComponent>();
                Game.Scene.AddComponent <AsyncImageDownloadComponent>();

                //棋牌游戏类型
                Game.Scene.AddComponent <ClientComponent>();
                // 下载ab包
                await BundleHelper.DownloadBundle();

                if (Define.UseEditorResouces)
                {
                    Game.Hotfix.LoadHotfixAssembly();
                    // 加载配置
                    Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                    Game.Scene.AddComponent <ConfigComponent>();
                    Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                    Game.Scene.AddComponent <OpcodeTypeComponent>();
                    Game.Scene.AddComponent <MessageDispatcherComponent>();
                    Game.Scene.AddComponent <SoundComponent>();
                    Game.Scene.AddComponent <ETimerComponent>();
                    Game.Scene.AddComponent <SimpleObjectPoolComponent>();
                    Game.Scene.AddComponent <OpenInstallComponent>();
                    Game.Scene.AddComponent <QRCodeComponent>();
                    Game.Scene.AddComponent <StageScaleModeComponent>();
                    Game.Scene.AddComponent <LocalizationComponent>();
                    StageScaleModeComponent.Instance.ChangeScaleMode(StageScaleMode.FULL_SCREEN);
                    Game.Hotfix.GotoHotfix();
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #11
0
        private async ETVoid StartAsync()
        {
            try
            {
#if UNITY_EDITOR
                Define.IsAsync = isNetworkBundle;
#endif

#if PLATFORM_STANDALONE_WIN
                Log.Debug("修改分辨率了啊");
                Screen.SetResolution(640, 360, false);
#endif


                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();

                gameObject.AddComponent <CoroutineMgr>();           //添加协程管理类
                // 下载ab包
                await BundleHelper.DownloadBundle();

                //加载热更项目
                Game.Hotfix.LoadHotfixAssembly();
                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                //消息分派组件
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();
                //直接添加Session组件
                Game.Scene.AddComponent <SessionComponent>();

                //执行热更项目
                Game.Hotfix.GotoHotfix();
                //Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #12
0
ファイル: Init.cs プロジェクト: ysb860331/ETCore
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                ClientConfigHelper.SetConfigHelper();
                Game.EventSystem.Add(DLLType.Core, typeof(Core).Assembly);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);
                //Log.Info(typeof(Core).Assembly.ToString());

                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                //Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                UnitConfig unitConfig = (UnitConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(UnitConfig), 1001);
                Log.Debug($"config {JsonHelper.ToJson(unitConfig)}");

                // 网络同步方式组件
                Game.Scene.AddComponent <NetSyncComponent, SyncType>(SyncType.State);

                //Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.InitSceneStart);

                //Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #13
0
ファイル: Init.cs プロジェクト: 510264505/ETCow
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                //通过反射机制,获取特性来加载DLL里面的类
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <TimerComponent>();
                //全局配置组件(热更新服务器地址等)
                Game.Scene.AddComponent <GlobalConfigComponent>();
                //网络连接组件(跟服务器通信)
                Game.Scene.AddComponent <NetOuterComponent>();
                //资源管理组件(热更新资源管理,AB包)
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                //UI管理组件
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                // 加载热更新代码DLL
                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                //协议类型组件,标识码
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                //消息分发组件
                Game.Scene.AddComponent <MessageDispatcherComponent>();
                //保存User信息及ID
                Game.Scene.AddComponent <ClientComponent>();
                //执行热更,热更层的入口
                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #14
0
ファイル: Init.cs プロジェクト: wincc0823/LandlordsCore
        private async void Start()
        {
            try
            {
                if (Application.unityVersion != "2017.1.0p5")
                {
                    Log.Warning($"当前版本:{Application.unityVersion}, 最好使用运行指南推荐版本!");
                }

                SynchronizationContext.SetSynchronizationContext(this.contex);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <BehaviorTreeComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();

                //斗地主客户端自定义全局组件
                //用于保存玩家本地数据
                Game.Scene.AddComponent <ClientComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #15
0
        private async void Start()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                //帧同步服务器
                //Game.Scene.AddComponent<ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                //加载声音,讲道理这里也要添加一个组件,声音的中间层
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("audiocontroller.unity3d");
                GameObject audiocontroller = (GameObject)Game.Scene.GetComponent <ResourcesComponent>().GetAsset("audiocontroller.unity3d", "AudioController");
                GameObject.Instantiate(audiocontroller);

                //加载字体组件
                Game.Scene.AddComponent <FontComponent>();

                Game.Hotfix.GotoHotfix();
                //给热更层发消息
                //Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #16
0
        private async void Start()
        {
            try
            {
                if (!Application.unityVersion.StartsWith("2017.4"))
                {
                    Log.Error($"新人请使用Unity2017.4版本,减少跑demo遇到的问题! 下载地址:\n https://unity3d.com/cn/unity/qa/lts-releases?_ga=2.227583646.282345691.1536717255-1119432033.1499739574");
                }

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                // Game.Scene.AddComponent<UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                //新Ui
                Log.Debug("加载UI框架");
                Game.Scene.AddComponent <UIManagerComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #17
0
        private async ETVoid StartAsync()
        {
            try
            {
                //上下文同步
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                //禁止销毁 在切换场景的时候
                DontDestroyOnLoad(gameObject);

                //遍历Model的程序集 缓存各个加了特性标签的对象
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <TimerComponent>();        //计时器
                Game.Scene.AddComponent <GlobalConfigComponent>(); //全局配置
                Game.Scene.AddComponent <NetOuterComponent>();     //外网组件 提供创建网络通道 在每个通道内部维护消息是收发处理
                Game.Scene.AddComponent <ResourcesComponent>();    //资源组件 提供AB加载
                Game.Scene.AddComponent <PlayerComponent>();       //玩家组件 提供玩家管理
                Game.Scene.AddComponent <UnitComponent>();         //单位组件 它的实体加了HideInHierarchy 表示在层级视图中隐藏
                Game.Scene.AddComponent <UIComponent>();           //UI组件

                // 下载ab包
                await BundleHelper.DownloadBundle();

                //加载热更新代码
                Game.Hotfix.LoadHotfixAssembly();

                // 加载资源配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                UnitConfig unit = (UnitConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(UnitConfig), 1);
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                //操作码 协议号
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                //消息分发
                Game.Scene.AddComponent <MessageDispatcherComponent>();
                //初始化IL
                Game.Hotfix.GotoHotfix();
                //测试热修复订阅事件
                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #18
0
ファイル: Init.cs プロジェクト: 91JiaoTeacher/ETLearn_V5.0
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <ResourcesAsyncComponent>();
                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <UIComponent>();


                if (!Assets.development)
                {
                    //下载地址
                    //Assets.downloadURL = @"http://192.168.50.2:9191/";
                    Assets.downloadURL = GlobalConfigComponent.Instance.GlobalProto.AssetBundleServerUrl;
                    //Assets.downloadURL = @"file://" + Application.dataPath + "/../../LoaclServer/";

                    // 下载ab包
                    await BundleHelper.DownloadBundle();
                }

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle("config.unity3d");
                //Game.Scene.AddComponent<ConfigComponent>();
                //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle("config.unity3d");

                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                Game.Hotfix.GotoHotfix();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #19
0
        private async void Start()
        {
            try
            {
                if (Application.unityVersion != "2017.4.3f1")
                {
                    Log.Error($"新人请使用Unity2017.4.3f1,减少跑demo遇到的问题! 下载地址:\n https://download.unity3d.com/download_unity/21ae32b5a9cb/UnityDownloadAssistant-2017.4.3f1.exe");
                }

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                //Game.Scene.AddComponent<BehaviorTreeComponent>();
                //Game.Scene.AddComponent<PlayerComponent>();
                //Game.Scene.AddComponent<UnitComponent>();
                //Game.Scene.AddComponent<ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle("config.unity3d");
                //Game.Scene.AddComponent<ConfigComponent>();
                //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #20
0
        private async void OnButtonClick_Enter()
        {
            switch (this.downloadState)
            {
            case DownloadState.Begin:
            case DownloadState.Retry:
                // 下载
                SetState(DownloadState.Quit);
                await BundleHelper.DownloadBundle();

                break;

            case DownloadState.Done:
                // 完成
                Done();
                break;

            case DownloadState.Quit:
                // 退出游戏
                Application.Quit();
                break;
            }
        }
コード例 #21
0
ファイル: Init.cs プロジェクト: Greatdust/ET4.0
        private async void Start()
        {
            try
            {
                if (!Application.unityVersion.StartsWith("2017.4"))
                {
                    Log.Error($"新人请使用Unity2017.4版本,减少跑demo遇到的问题! 下载地址:\n https://unity3d.com/cn/unity/qa/lts-releases?_ga=2.227583646.282345691.1536717255-1119432033.1499739574");
                }

                //线程同步队列,对socket的回调进行排序调用
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);                 //这个类会一直保留

                //通过反射机制,获取特性得到DLL里面的类
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                //全局配置组件 (热更新资源地址,服务器ID端口)
                Game.Scene.AddComponent <GlobalConfigComponent>();

                //网络通信组件(和服务器通信)
                Game.Scene.AddComponent <NetOuterComponent>();

                //资源管理组件 (热更资源的管理,AB包)
                Game.Scene.AddComponent <ResourcesComponent>();

                //玩家组建 DEMO使用的
                Game.Scene.AddComponent <PlayerComponent>();

                //DEMO使用的
                Game.Scene.AddComponent <UnitComponent>();

                //帧同步组件
                Game.Scene.AddComponent <ClientFrameComponent>();

                //UI组件
                Game.Scene.AddComponent <UIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                //加载热更新资源
                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                //协议类型组件
                Game.Scene.AddComponent <OpcodeTypeComponent>();

                //消息分发
                Game.Scene.AddComponent <MessageDispatherComponent>();

                //执行热更层的代码
                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #22
0
ファイル: Init.cs プロジェクト: spadd/ET_Tank
        private async ETVoid StartAsync()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                // 全局配置  GlobalProto.txt
                // {"AssetBundleServerUrl":"http://127.0.0.1:8080/","Address":"127.0.0.1:10002"}
                Game.Scene.AddComponent <GlobalConfigComponent>();

                // 网络组件连接组件(跟服务器通信)
                Game.Scene.AddComponent <NetOuterComponent>();

                // 资源管理组件(热更新资源的管理,AB包)
                Game.Scene.AddComponent <ResourcesComponent>();

                Game.Scene.AddComponent <PlayerComponent>();

                Game.Scene.AddComponent <UnitComponent>();

                Game.Scene.AddComponent <TankComponent>();

                Game.Scene.AddComponent <NumericWatcherComponent>();


                // FGUI包管理
                Game.Scene.AddComponent <FUIPackageComponent>();



                // FGUI组件管理
                Game.Scene.AddComponent <FUIComponent>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                await Game.Scene.GetComponent <FUIPackageComponent>().CreateConstPackage();

                // 加载热更新
                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");

                //
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                // 协议类型
                Game.Scene.AddComponent <OpcodeTypeComponent>();

                // 消息分发 (客户端跟服务器通讯,进行消息的分发传递)
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                // 执行热更层Hotfix的入口
                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #23
0
ファイル: Init.cs プロジェクト: wqaetly/NKGMobaBasedOnET
        private async ETVoid StartAsync()
        {
            try
            {
                BsonHelper.Init();
                ForwardRenderBridge.Instance.Init();

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);
                DontDestroyOnLoad(gameObject);
                DontDestroyOnLoad(MainCamera);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <NumericWatcherComponent>();

                fixedUpdate = new FixedUpdate()
                {
                    UpdateCallback = () => Game.EventSystem.FixedUpdate()
                };

                Game.Scene.AddComponent <TimerComponent>();

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <PlayerComponent>();

                Game.Scene.AddComponent <CoroutineLockComponent>();
                Game.Scene.AddComponent <UnitComponent>();

                Game.Scene.AddComponent <FUIPackageComponent>();
                Game.Scene.AddComponent <FUIComponent>();
                Game.Scene.AddComponent <FUIInitComponent>();

                //用户输入管理组件
                Game.Scene.AddComponent <UserInputComponent>();
                Game.Scene.AddComponent <CampAllocManagerComponent>();
                Game.Scene.AddComponent <MouseTargetSelectorComponent>();

                Game.Scene.AddComponent <GameObjectPool>();

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.AddComponent <ConfigComponent>();

                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                Game.Scene.AddComponent <HeroBaseDataRepositoryComponent>();

                Game.Scene.AddComponent <B2S_DebuggerComponent>();

                Game.Hotfix.GotoHotfix();

                Game.Scene.AddComponent <NP_SyncComponent>();
                Game.Scene.AddComponent <NP_TreeDataRepository>();

                Game.Scene.AddComponent <CDComponent>();
                Game.Scene.AddComponent <SoundComponent>();
                Game.Scene.GetComponent <SoundComponent>().PlayMusic("Sound_BGM", 0, 0.4f, true);

                //战斗系统的事件系统组件
                Game.Scene.AddComponent <BattleEventSystem>();
                //UnitFactory.NPBehaveTestCreate();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #24
0
        private async ETVoid StartAsync()
        {
            try
            {
                // SynchronizationContext类是用于多线程之间通信的一个类,其在通讯中充当了个传输者的角色
                //异步Socket每次接收一步就会单独分出一个线程
                //这里使异步方法全部会回调到主线程,进行Socket线程队列同步
                //最后让收到的所有消息都是有序的
                //搞懂 SynchronizationContext(第一部分)【翻译】:https://www.cnblogs.com/lzxianren/p/SynchronizationContext.html
                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);
                //我懂了?!!


                //挂载DebuggerComponent
                gameObject.AddComponent <DebuggerComponent>();

                //通知Unity这个GameObject永远不会销毁
                DontDestroyOnLoad(gameObject);

                //反射当前所有dll,添加到反射系统        Model.dll      类型Init的程序集
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                //计时器
                Game.Scene.AddComponent <TimerComponent>();
                //全局配置数据(服务器的链接IP、资源服务器的HTTP地址)
                Game.Scene.AddComponent <GlobalConfigComponent>();
                //联网组件(进行服务器通讯用的组件)
                Game.Scene.AddComponent <NetOuterComponent>();
                //热更新资源(资源管理,AB包)
                Game.Scene.AddComponent <ResourcesComponent>();
                //所有玩家(用户信息、等)
                Game.Scene.AddComponent <PlayerComponent>();
                //游戏单元 (Demo用的:骷髅模型)
                Game.Scene.AddComponent <UnitComponent>();
                //ET的UI框架组件(掌管着ET的UI)
                Game.Scene.AddComponent <UIComponent>();



                // 下载ab包
                await BundleHelper.DownloadBundle();

                //读取热更代码 ILRuntime VM
                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置 描所有的带config.unity3d的ConfigAttribute标签的配置包(配置文件在Res/Config文件夹,并带有config.untiy3d标签)
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");

                //消息代码识别码组件(操作码等)
                Game.Scene.AddComponent <OpcodeTypeComponent>();

                //消息分发组件    收到消息后由哪个handler调用处理
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                //进入热更层,执行ETHotfix.Init()
                Game.Hotfix.GotoHotfix();

                //测试    分发数值监听事件
                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #25
0
        private async ETVoid StartAsync()
        {
            try
            {
                Application.runInBackground = true;
#if UNITY_IOS || UNITY_ANDROID
                // Application.runInBackground = true;
                // Application.targetFrameRate = 60;
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
#endif

#if LOG_ZSX
                var nodes = GameObject.Find("LoginCanvas");
                if (nodes != null)
                {
                    var node = nodes.GetComponentsInChildren <RectTransform>();
                    for (int i = 0; i < node.Length; i++)
                    {
                        node[i].gameObject.SetActive(false);
                    }
                    nodes.SetActive(true);
                }
#endif

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <TimerComponent>();
                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <LocalResourcesComponent>();
                // Game.Scene.AddComponent<PlayerComponent>();
                // Game.Scene.AddComponent<UnitComponent>();

                Game.Scene.AddComponent <NetHttpComponent>();

                Game.Scene.AddComponent <UIComponent>();
                Game.Scene.AddComponent <NetLineSwitchComponent>();

#if UNITY_IOS
                TimerComponent iOSTimerComponent = Game.Scene.GetComponent <TimerComponent>();
                while (true)
                {
                    await iOSTimerComponent.WaitAsync(200);

                    if (UnityEngine.Application.internetReachability != NetworkReachability.NotReachable)
                    {
                        break;
                    }
                }
#endif

                // 安装包更新
                await InstallPacketHelper.CheckInstallPacket();

                if (InstallPacketHelper.NeedInstallPacket())
                {
                    InstallPacketDownloaderComponent mInstallPacketDownloaderComponent = Game.Scene.GetComponent <InstallPacketDownloaderComponent>();

                    if (null != mInstallPacketDownloaderComponent)
                    {
                        bool mWaitting = true;

                        string[] mArr         = mInstallPacketDownloaderComponent.remoteInstallPacketConfig.Msg.Split(new string[] { "@%" }, StringSplitOptions.None);
                        int      mTmpLanguage = PlayerPrefsMgr.mInstance.GetInt(PlayerPrefsKeys.KEY_LANGUAGE, 2);
                        if (mTmpLanguage < 0)
                        {
                            mTmpLanguage = 0;
                        }
                        int mGroup = mArr.Length / 3;
                        if (mTmpLanguage < mGroup)
                        {
                            UIComponent.Instance.ShowNoAnimation(UIType.UIDialog,
                                                                 new UIDialogComponent.DialogData()
                            {
                                type          = UIDialogComponent.DialogData.DialogType.Commit,
                                title         = mArr[mTmpLanguage],
                                content       = mArr[mTmpLanguage + mGroup],
                                contentCommit = mArr[mTmpLanguage + 2 * mGroup],
                                contentCancel = string.Empty,
                                actionCommit  = () => { mWaitting = false; },
                                actionCancel  = null
                            });

                            TimerComponent mUpdateTimerComponent = Game.Scene.GetComponent <TimerComponent>();
                            while (mWaitting)
                            {
                                await mUpdateTimerComponent.WaitAsync(200);
                            }
                            UIComponent.Instance.Remove(UIType.UIDialog);
                        }
                    }

#if UNITY_ANDROID
                    switch (UnityEngine.Application.internetReachability)
                    {
                    case NetworkReachability.ReachableViaCarrierDataNetwork:
                        // "当前为运行商网络(2g、3g、4g)"
                        string mTmpMsg      = string.Empty;
                        int    mTmpLanguage = PlayerPrefsMgr.mInstance.GetInt(PlayerPrefsKeys.KEY_LANGUAGE, 2);
                        switch (mTmpLanguage)
                        {
                        case 0:
                            mTmpMsg = $"当前使用移动数据,需要消耗{mInstallPacketDownloaderComponent.remoteInstallPacketConfig.ApkSize / (1024 * 1024)}M流量,是否继续下载?";
                            break;

                        case 1:
                            mTmpMsg = $"The current use of mobile data, need to consume {mInstallPacketDownloaderComponent.remoteInstallPacketConfig.ApkSize / (1024 * 1024)} M, whether to download?";
                            break;

                        case 2:
                            mTmpMsg = $"當前使用移動數據,需要消耗{mInstallPacketDownloaderComponent.remoteInstallPacketConfig.ApkSize / (1024 * 1024)}M流量,是否繼續下載?";
                            break;
                        }
                        Game.Scene.GetComponent <UIComponent>().Show(UIType.UICarrierDataNetwork, new UICarrierDataNetworkComponent.UICarrierDataNetworkData()
                        {
                            Msg      = mTmpMsg,
                            Callback = async() =>
                            {
                                await InstallPacketHelper.DownloadInstallPacket();
                                // Log.Debug($"下载完啦!");
                                // todo 调起安装
                                NativeManager.OpenApk(InstallPacketHelper.InstallPacketPath());
                            }
                        }, null, 0);
                        break;

                    case NetworkReachability.ReachableViaLocalAreaNetwork:
                        // wifi网络
                        await InstallPacketHelper.DownloadInstallPacket();

                        // todo 调起安装
                        NativeManager.OpenApk(InstallPacketHelper.InstallPacketPath());
                        return;
                    }
#elif UNITY_IOS
                    UnityEngine.Application.OpenURL(mInstallPacketDownloaderComponent.remoteInstallPacketConfig.IOSUrl);
                    Application.Quit();
#endif
                    return;
                }



                // 下载ab包
                await BundleHelper.CheckDownloadBundle();

                BundleHelper.IsDownloadBundleFinish = false;
                if (BundleHelper.NeedDownloadBundle())
                {
#if UNITY_IOS
                    bool AppStorePack = false;
#if APPStore
                    AppStorePack = true;
#endif
                    InstallPacketDownloaderComponent mInstallPacketDownloaderComponent = Game.Scene.GetComponent <InstallPacketDownloaderComponent>();
                    if (!mInstallPacketDownloaderComponent.remoteInstallPacketConfig.CheckRes && AppStorePack)
                    {
                        BundleHelper.DownloadBundleFinish();
                    }
                    else
#endif
                    {
                        BundleDownloaderComponent mBundleDownloaderComponent = Game.Scene.GetComponent <BundleDownloaderComponent>();
                        switch (UnityEngine.Application.internetReachability)
                        {
                        case NetworkReachability.ReachableViaCarrierDataNetwork:
                            // "当前为运行商网络(2g、3g、4g)"
                            string mTmpMsg      = string.Empty;
                            int    mTmpLanguage = PlayerPrefsMgr.mInstance.GetInt(PlayerPrefsKeys.KEY_LANGUAGE, 2);
                            switch (mTmpLanguage)
                            {
                            case 0:
                                mTmpMsg = $"当前使用移动数据,需要消耗{mBundleDownloaderComponent.TotalSize / (1024 * 1024)}M流量,是否继续下载?";
                                break;

                            case 1:
                                mTmpMsg = $"The current use of mobile data, need to consume {mBundleDownloaderComponent.TotalSize / (1024 * 1024)} M, whether to download?";
                                break;

                            case 2:
                                mTmpMsg = $"當前使用移動數據,需要消耗{mBundleDownloaderComponent.TotalSize / (1024 * 1024)}M流量,是否繼續下載?";
                                break;
                            }
                            Game.Scene.GetComponent <UIComponent>().ShowNoAnimation(UIType.UICarrierDataNetwork, new UICarrierDataNetworkComponent.UICarrierDataNetworkData()
                            {
                                Msg      = mTmpMsg,
                                Callback = async() =>
                                {
                                    await BundleHelper.DownloadBundle();
                                    BundleHelper.IsDownloadBundleFinish = true;
                                },
                            });
                            TimerComponent timerComponent = Game.Scene.GetComponent <TimerComponent>();
                            while (true)
                            {
                                await timerComponent.WaitAsync(1000);

                                if (BundleHelper.IsDownloadBundleFinish)
                                {
                                    break;
                                }
                            }
                            Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICarrierDataNetwork);
                            break;

                        case NetworkReachability.ReachableViaLocalAreaNetwork:
                            // wifi网络
                            await BundleHelper.DownloadBundle();

                            break;
                        }
                    }
                }
                else
                {
                    BundleHelper.DownloadBundleFinish();
                }

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatcherComponent>();

                Game.Hotfix.GotoHotfix();

                // Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }