Exemple #1
0
        /// <summary>
        /// Loads the instance asset async.
        /// 'assetBundlePath',只需要填相对路径,不用加后缀,如 UI/Panel/MenuPanel,除非ab不是按AssetConfig里面配置的后缀来设置的.
        /// 'assetName',只需要填相对路径,需要加后缀,如 UI/Panel/MenuPanel.prefab
        /// </summary>
        public InstanceAssetLoader LoadInstanceAssetAsync(string assetBundleRelativePath, string assetName, OnLoadInstanceAsset callback)
        {
            // 如果是加载ab中的资源,需要填完成的路径,这跟 BuildAssetBundleOptions 有关,参考BundleBuilder.BuildAssetBundle()
            if (!string.IsNullOrEmpty(assetBundleRelativePath))
            {
                assetName = AssetConfig.GetAssetFullPathInAB(assetName);
            }

            string fullRelativePath    = AssetConfig.GetAssetBundleFullRelativePath(assetBundleRelativePath);
            string assetBundleFullPath = AssetConfig.GetGameAssetFullPath(fullRelativePath);

            LoaderCallback internelHandler = (bool isOk, object resultObject) =>
            {
                if (isOk)
                {
                    callback.Invoke(resultObject as Object);
                }
                else
                {
                    callback.Invoke(null);
                }
            };

            return(BaseLoader.Load <InstanceAssetLoader>(assetBundleFullPath, assetName, callback: internelHandler));
        }
Exemple #2
0
        /// <summary>
        /// Loads the asset bundle async.
        /// 'assetBundlePath',只需要填相对路径,不用填后缀,如 UI/Panel/MenuPanel,除非ab不是按AssetConfig里面配置的后缀来设置的.
        /// </summary>

        public AssetBundleLoader LoadAssetBundleAsync(string assetBundleRelativePath, OnLoadAssetBundle callback)
        {
            string fullRelativePath    = AssetConfig.GetAssetBundleFullRelativePath(assetBundleRelativePath);
            string assetBundleFullPath = AssetConfig.GetGameAssetFullPath(fullRelativePath);

            LoaderCallback internelHandler = (bool isOk, object resultObject) =>
            {
                if (isOk)
                {
                    callback.Invoke(resultObject as AssetBundle);
                }
                else
                {
                    callback.Invoke(null);
                }
            };

            return(BaseLoader.Load <AssetBundleLoader>(assetBundleFullPath, "", callback: internelHandler));
        }