Ejemplo n.º 1
0
        private async UniTask DoLoadAsync()
        {
            LoadState = AssetLoadState.Loading;
            //正儿八经的开始加载了
            if (LoadedPath.StartsWith("jar:file://", StringComparison.Ordinal))
            {
                this.AssetBundle = await this.ABLoader.LoadAssetBundleFromAndroidStreamingAssetsAsync(LoadedPath, AssetBundleName, this.VirtualDiskPath);
            }
            else if (LoadedPath.StartsWith("http://", StringComparison.Ordinal) ||
                     LoadedPath.StartsWith("https://", StringComparison.Ordinal) ||
                     //LoadedPath.StartsWith("file://", StringComparison.Ordinal)||
                     LoadedPath.StartsWith("ftp://", StringComparison.Ordinal))
            {
                if (this.GroupHandleMode == GroupHandleMode.RemoteOnly)
                {
                    this.AssetBundle = await this.ABLoader.LoadAssetBundleFromWebAsync(LoadedPath, AssetBundleName, this.DownloadTimeout);
                }
                else
                {
                    await this.ABLoader.DownloadFile(LoadedPath, VirtualDiskPath, DownloadTimeout);

                    this.AssetBundle = await this.ABLoader.LoadAssetBundleFromFileAsync(this.VirtualDiskPath, this.AssetBundleName);
                }
            }
            else
            {
                this.AssetBundle = await this.ABLoader.LoadAssetBundleFromFileAsync(LoadedPath, AssetBundleName);
            }
        }
Ejemplo n.º 2
0
        //private BundlesManager bundlesManager;

        /// <summary>
        /// 同步加载
        /// </summary>
        internal void Load()
        {
            if (this.LoadState == AssetLoadState.Loaded && this.AssetBundle != null)
            {
                return;
            }
            if (LoadState == AssetLoadState.Unloaded)
            {
                throw new VFSException("[TinaX.VFS] Error: Attempt to load an unloaded assetbundle :" + this.AssetBundleName);
            }


            LoadState = AssetLoadState.Loading; //其实这时候改没啥用
            if (LoadedPath.StartsWith("jar:file://", StringComparison.Ordinal))
            {
                this.AssetBundle = this.ABLoader.LoadAssetBundleFromAndroidStreamingAssets(this.LoadedPath, this.AssetBundleName, this.VirtualDiskPath);
            }
            else if (LoadedPath.StartsWith("http://", StringComparison.Ordinal) ||
                     LoadedPath.StartsWith("https://", StringComparison.Ordinal) ||
                     //LoadedPath.StartsWith("file://", StringComparison.Ordinal)||
                     LoadedPath.StartsWith("ftp://", StringComparison.Ordinal))
            {
                throw new VFSException("[TinaX.VFS] Error: Connot load from network sync");
            }
            else
            {
                this.AssetBundle = ABLoader.LoadAssetBundleFromFile(this.LoadedPath, this.AssetBundleName);
            }

            LoadState = AssetLoadState.Loaded;
        }