Exemple #1
0
        /// <summary>
        /// 同步加载assetbundle
        /// </summary>
        /// <param name="assetBundleName"></param>
        /// <returns></returns>
        public async Task LoadBundleAsync <T>(string assetBundleName) where T : UnityEngine.Object
        {
            assetBundleName = assetBundleName.ToLower();
            string[] dependencies = ResourcesHelper.GetSortedDependencies(assetBundleName);

            //Log.Debug($"-----------dep load {assetBundleName} dep: {dependencies.ToList().ListToString()}");
            foreach (string dependency in dependencies)
            {
                if (string.IsNullOrEmpty(dependency))
                {
                    continue;
                }
                if (assetBundleName.Equals(dependency))
                {
                    await this.LoadOneBundleAsync <T>(dependency);
                }
                else
                {
                    await this.LoadOneBundleAsync(dependency);
                }
            }
        }
Exemple #2
0
        public async Task <UI> CreateAsync(Scene scene, string type, GameObject parent)
        {
            try
            {
                UnityEngine.Object obj = await ResourcesHelper.LoadAsync("KV");

                GameObject bundleGameObject = ((GameObject)obj).Get <GameObject>(type);
                GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);
                go.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI ui = ComponentFactory.Create <UI, GameObject>(go);

                ui.AddUIBaseComponent <UIDialogComponent>();

                AddSubComponent(ui);

                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(null);
            }
        }
        public override byte[] FileOpen(string filePath, string ext = null)
        {
            GameObject kv = (GameObject)ResourcesHelper.Load("KV");

            return(kv.Get <TextAsset>(filePath).bytes);
        }