Example #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);
        }
Example #2
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));
        }
        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;
        }