Exemple #1
0
        private static Bundle LoadInternal(string assetBundleName, bool isLoadingAssetBundleManifest, bool asyncRequest)
        {
            if (!isLoadingAssetBundleManifest)
            {
                if (manifest == null)
                {
                    Logger.L(LogType.Error, "Bundles", "Please initialize AssetBundleManifest by calling Bundles.Initialize()");
                    return(null);
                }
                assetBundleName = RemapVariantName(assetBundleName);
            }
            Bundle bundle = bundles.Find(obj => { return(obj.name == assetBundleName); });

            if (bundle == null)
            {
                if (asyncRequest)
                {
                    bundle = new BundleAsync(assetBundleName, !isLoadingAssetBundleManifest);
                }
                else
                {
                    bundle = new Bundle(assetBundleName, !isLoadingAssetBundleManifest);
                }
                bundles.Add(bundle);
            }
            bundle.Load();
            return(bundle);
        }
Exemple #2
0
        static Bundle LoadInternal(string assetBundleName, bool isLoadingAssetBundleManifest, bool asyncRequest)
        {
            if (!isLoadingAssetBundleManifest)
            {
                if (manifest == null)
                {
                    Logger.L(LogType.Error, "Bundles", "Please initialize AssetBundleManifest by calling Bundles.Initialize()");
                    return(null);
                }
                assetBundleName = RemapVariantName(assetBundleName);
            }

            var    url    = Bundles.GetDataPath(assetBundleName) + assetBundleName;
            Bundle bundle = bundles.Find(obj => {
                return(obj.name == assetBundleName);
            });

            var hash = isLoadingAssetBundleManifest ? new Hash128(1, 0, 0, 0) : manifest.GetAssetBundleHash(assetBundleName);

            if (bundle == null)
            {
                if (url.StartsWith("http://") ||
                    url.StartsWith("https://") ||
                    url.StartsWith("file://") ||
                    url.StartsWith("ftp://"))
                {
                    bundle = new BundleWWW(url, hash);
                }
                else
                {
                    if (asyncRequest)
                    {
                        bundle = new BundleAsync(url, hash);
                    }
                    else
                    {
                        bundle = new Bundle(url, hash);
                    }
                }
                bundle.name = assetBundleName;
                bundles.Add(bundle);
                bundle.Load();
                if (!isLoadingAssetBundleManifest)
                {
                    LoadDependencies(bundle, assetBundleName, asyncRequest);
                }
            }
            bundle.Retain();
            return(bundle);
        }