예제 #1
0
        /// <summary>
        /// 加载资源的异步委托
        /// </summary>
        /// <param name="name">注意,这个name是FGUI内部组装的纹理全名,例如FUILogin_atlas0</param>
        /// <param name="extension"></param>
        /// <param name="type"></param>
        /// <param name="item"></param>
        private async void LoadPackageInternalAsync(string name, string extension, System.Type type, PackageItem item)
        {
            Texture texture =
                await XAssetLoader.LoadAssetAsync <Texture>(XAssetPathUtilities.GetFGUIResPath(name, extension));

            item.owner.SetItemAsset(item, texture, DestroyMethod.Unload);
        }
예제 #2
0
        public void GetAllConfigBytes(Dictionary <string, byte[]> output)
        {
            var types = Game.EventSystem.GetTypes(typeof(ConfigAttribute));

            foreach (var kv in types)
            {
                output[kv.Name] = XAssetLoader.LoadAsset <TextAsset>(XAssetPathUtilities.GetNormalConfigPath(kv.Name)).bytes;
            }
        }
예제 #3
0
        public async ETTask AddPackageAsync(string type)
        {
            if (s_Packages.ContainsKey(type))
            {
                await ETTask.CompletedTask;
            }

            TextAsset desTextAsset =
                await XAssetLoader.LoadAssetAsync <TextAsset>(XAssetPathUtilities.GetFGUIDesPath($"{type}_fui"));

            s_Packages.Add(type, UIPackage.AddPackage(desTextAsset.bytes, type, LoadPackageInternalAsync));
        }
예제 #4
0
        protected override async ETTask Run(EventType.AfterUnitCreate args)
        {
            // Unit View层
            // 这里可以改成异步加载,demo就不搞了
            GameObject bundleGameObject =
                await XAssetLoader.LoadAssetAsync <GameObject>(XAssetPathUtilities.GetUnitPath("Unit"));

            GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton");

            GameObject go = UnityEngine.Object.Instantiate(prefab, GlobalComponent.Instance.Unit, true);

            go.transform.position = args.Unit.Position;
            args.Unit.AddComponent <GameObjectComponent>().GameObject = go;
            args.Unit.AddComponent <AnimatorComponent>();
            await ETTask.CompletedTask;
        }
예제 #5
0
        /// <summary>
        /// 移除一个包,并清理其asset
        /// </summary>
        /// <param name="type"></param>
        public void RemovePackage(string type)
        {
            UIPackage package;

            if (s_Packages.TryGetValue(type, out package))
            {
                var p = UIPackage.GetByName(package.name);
                if (p != null)
                {
                    UIPackage.RemovePackage(package.name);
                    XAssetLoader.UnLoadAsset(XAssetPathUtilities.GetFGUIDesPath($"{type}_fui"));
                    XAssetLoader.UnLoadAsset(XAssetPathUtilities.GetFGUIResPath($"{type}_atlas0", ".png"));
                }

                s_Packages.Remove(package.name);
            }
        }
예제 #6
0
        private async ETVoid InternalAwake()
        {
            try
            {
                // 设置全局模式
                GlobalDefine.ILRuntimeMode = this.ILRuntimeMode;
                GlobalDefine.DevelopMode   = this.DevelopMode;
                GlobalDefine.SetLoginAddress(LoginAddress);

                // 限制帧率,尽量避免手机发烫
                QualitySettings.vSyncCount  = 0;
                Application.targetFrameRate = 60;

                SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);

                // 初始化FGUI系统
                FUIEntry.Init();

                Updater updater = this.GetComponent <Updater>();
                m_XAssetUpdater = new XAssetUpdater(updater);

                FUI_CheckForResUpdateComponent.Init(m_XAssetUpdater.Updater);

                await m_XAssetUpdater.StartUpdate();

                byte[] dllByte = XAssetLoader.LoadAsset <TextAsset>(XAssetPathUtilities.GetHotfixDllPath("Hotfix"))
                                 .bytes;
                byte[] pdbByte = XAssetLoader.LoadAsset <TextAsset>(XAssetPathUtilities.GetHotfixPdbPath("Hotfix"))
                                 .bytes;

                HotfixHelper.GoToHotfix(dllByte, pdbByte);

                GloabLifeCycle.StartAction?.Invoke();
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw;
            }
        }
예제 #7
0
 public byte[] GetOneConfigBytes(string configName)
 {
     return(XAssetLoader.LoadAsset <TextAsset>(XAssetPathUtilities.GetNormalConfigPath(configName)).bytes);;
 }