private void Update() { for (var i = 0; i < _assets.Count; i++) { var item = _assets [i]; if (item.Update() || !item.IsUnused()) { continue; } _unusedAssets.Add(item); _assets.RemoveAt(i); i--; } for (var i = 0; i < _unusedAssets.Count; i++) { var item = _unusedAssets [i]; item.Unload(); Log("Unload->" + item.name); } _unusedAssets.Clear(); Bundles.Update(); }
private static void InitBundles(Action onSuccess, Action <string> onError) { Bundles.OverrideBaseDownloadingUrl += Bundles_overrideBaseDownloadingURL; Bundles.Initialize(() => { var asset = LoadAsync(Assets.AssetsManifestAsset, typeof(AssetManifest)); asset.completed += obj => { var manifest = obj.asset as AssetManifest; if (manifest == null) { if (onError != null) { onError.Invoke("manifest == null"); } return; } downloadURL = Path.Combine(manifest.downloadURL, platform) + Path.DirectorySeparatorChar; Bundles.activeVariants = manifest.activeVariants; _bundles = manifest.bundles; var dirs = manifest.dirs; _bundleAssets.Clear(); for (int i = 0, max = manifest.assets.Length; i < max; i++) { var item = manifest.assets [i]; _bundleAssets [string.Format("{0}/{1}", dirs [item.dir], item.name)] = item.bundle; } if (onSuccess != null) { onSuccess.Invoke(); } obj.Release(); }; }, onError); }
internal override void Load() { bundle = Bundles.Load(assetBundleName); var assetName = Path.GetFileName(name); asset = bundle.assetBundle.LoadAsset(assetName, assetType); }
internal override void Load() { if (!string.IsNullOrEmpty(assetBundleName)) { bundle = Bundles.LoadAsync(assetBundleName); loadState = LoadState.LoadAssetBundle; } else { _request = SceneManager.LoadSceneAsync(sceneName, loadSceneMode); loadState = LoadState.LoadAsset; } }
internal override void Load() { if (!string.IsNullOrEmpty(assetBundleName)) { bundle = Bundles.Load(assetBundleName); if (bundle != null) { SceneManager.LoadScene(sceneName, loadSceneMode); } } else { SceneManager.LoadScene(sceneName, loadSceneMode); } }
public static string[] GetAllDependencies(string path) { string assetBundleName; return(GetAssetBundleName(path, out assetBundleName) ? Bundles.GetAllDependencies(assetBundleName) : null); }
public static void Initialize(Action onSuccess, Action <string> onError) { var instance = FindObjectOfType <Assets>(); if (instance == null) { instance = new GameObject("Assets").AddComponent <Assets>(); DontDestroyOnLoad(instance.gameObject); } if (string.IsNullOrEmpty(Utility.dataPath)) { Utility.dataPath = Application.streamingAssetsPath; } Log(string.Format("Init->assetBundleMode {0} | dataPath {1}", Utility.assetBundleMode, Utility.dataPath)); if (Utility.assetBundleMode) { updatePath = Utility.updatePath; var platform = Utility.GetPlatform(); var path = Path.Combine(Utility.dataPath, Path.Combine(Utility.AssetBundles, platform)) + Path.DirectorySeparatorChar; Bundles.OverrideBaseDownloadingUrl += Bundles_overrideBaseDownloadingURL; Bundles.Initialize(path, platform, () => { var asset = LoadAsync(Utility.AssetsManifestAsset, typeof(AssetsManifest)); asset.completed += obj => { var manifest = obj.asset as AssetsManifest; if (manifest == null) { if (onError != null) { onError("manifest == null"); } return; } if (string.IsNullOrEmpty(Utility.downloadURL)) { Utility.downloadURL = manifest.downloadURL; } Bundles.activeVariants = manifest.activeVariants; _bundles = manifest.bundles; var dirs = manifest.dirs; _bundleAssets = new Dictionary <string, int>(manifest.assets.Length); for (int i = 0, max = manifest.assets.Length; i < max; i++) { var item = manifest.assets[i]; _bundleAssets[string.Format("{0}/{1}", dirs[item.dir], item.name)] = item.bundle; } if (onSuccess != null) { onSuccess(); } obj.Release(); }; }, onError); } else { if (onSuccess != null) { onSuccess(); } } }
internal override void Load() { bundle = Bundles.LoadAsync(assetBundleName); loadState = LoadState.LoadAssetBundle; }