public override void Initialize() { var path = Helper.GetInternalPath(name.ToLower()); _request = AssetBundle.LoadFromFileAsync(path); if (_request == null) { error = name + " LoadFromFileAsync falied."; } var items = Bundles.GetBundleDependencies(name.ToLower()); if (items != null && items.Length > 0) { for (int i = 0, I = items.Length; i < I; i++) { var item = items[i]; if (Bundles.IsCyclicDependsLoaded(item)) { Debug.LogWarning("Cyclic dependence " + name); } else { dependencies.Add(Bundles.LoadAsync(item)); } } } }
public override void Initialize() { var path = Helper.GetDataPath(name.ToLower()); if (Bundles.IsInternal(name)) { path = "file:///" + Helper.GetInternalPath(name); } _request = UnityWebRequestAssetBundle.GetAssetBundle(path, Bundles.GetHash128(name), 0); _request.SendWebRequest(); if (_request == null) { error = name + " LoadFromFileAsync falied."; } var items = Bundles.GetBundleDependencies(name.ToLower()); if (items != null && items.Length > 0) { for (int i = 0, I = items.Length; i < I; i++) { var item = items[i]; if (Bundles.IsCyclicDependsLoaded(item)) { Debug.LogWarning("Cyclic dependence " + name); } else { dependencies.Add(Bundles.LoadAsync(item)); } } } }
public override void Initialize() { var path = Helper.GetInternalPath(name); _assetBundle = AssetBundle.LoadFromFile(path); if (_assetBundle == null) { error = name + " LoadFromFile failed."; } var items = Bundles.GetBundleDependencies(name.ToLower()); if (items != null && items.Length > 0) { for (int i = 0, I = items.Length; i < I; i++) { var item = items[i]; if (Bundles.IsCyclicDependsLoaded(item)) { #if UNITY_EDITOR Debug.LogWarning("Cyclic dependence " + name); #endif } else { dependencies.Add(Bundles.Load(item)); } } } }
public virtual void Initialize() { var path = Helper.GetDataPath(name.ToLower()); //使用了Caching的资源 AssetBundle.LoadFromFile 找不到路径,这里直接阻塞等待加载完成, //按照官方文档上说的,对已经Cache的资源UnityWebRequest.GetAssetBundle 和 AssetBundle.LoadFromFile 功能一样,都会立刻返回 var _request = UnityWebRequestAssetBundle.GetAssetBundle(path, Bundles.GetHash128(name), 0); _request.SendWebRequest(); while (!_request.isDone) { Thread.Yield(); } _assetBundle = DownloadHandlerAssetBundle.GetContent(_request); _request.Dispose(); if (_assetBundle == null) { error = name + " LoadFromFile failed."; } var items = Bundles.GetBundleDependencies(name.ToLower()); if (items != null && items.Length > 0) { for (int i = 0, I = items.Length; i < I; i++) { var item = items [i]; if (Bundles.IsCyclicDependsLoaded(item)) { #if UNITY_EDITOR Debug.LogWarning("Cyclic dependence " + name); #endif } else { dependencies.Add(Bundles.Load(item)); } } } }