internal override void Load() { bundle = Bundles.Load(assetBundleName); var assetName = Path.GetFileName(name); asset = bundle.assetBundle.LoadAsset(assetName, assetType); }
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(); }
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 AssetBundle LoadBundle(string assetBundleName) { if (string.IsNullOrEmpty(assetBundleName)) { Debug.LogError("invalid path"); return(null); } var bundle = Bundles.Load(assetBundleName); if (null != bundle) { return(bundle.assetBundle); } return(null); }
internal override void Load() { bundle = Bundles.LoadAsync(assetBundleName); loadState = LoadState.LoadAssetBundle; }
public static void Initialize(Action onSuccess, Action <string> onError) { var instance = FindObjectOfType <Assets>(); if (instance == null) { instance = new GameObject("AssetMgr").AddComponent <Assets>(); DontDestroyOnLoad(instance.gameObject); } if (string.IsNullOrEmpty(Utility.dataPath) || AppConst.SimulateMode) { 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, Utility.AssetBundles) + Path.DirectorySeparatorChar; Bundles.OverrideBaseDownloadingUrl += Bundles_overrideBaseDownloadingURL; Bundles.Initialize(path, platform, () => { var asset = LoadAsync(Utility.ManifestAsset, 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]; if (!string.IsNullOrEmpty(dirs[item.dir])) { _bundleAssets[string.Format("{0}/{1}", dirs[item.dir], item.name)] = item.bundle; } else { _bundleAssets[item.name] = item.bundle; } } if (onSuccess != null) { onSuccess(); } obj.Release(); }; }, onError); } else { if (onSuccess != null) { onSuccess(); } } }
public static string[] GetAllDependencies(string path) { string assetBundleName; return(GetAssetBundleName(path, out assetBundleName) ? Bundles.GetAllDependencies(assetBundleName) : null); }