protected override void OnLoad() { request = Bundles.LoadAsync(Assets.GetBundleName(assetPath)); }
internal void Load() { asset = Assets.Load(assetPath, assetType); }
protected override void OnLoad() { request = Bundles.Load(Assets.GetBundleName(assetPath)); asset = request.LoadAsset(Assets.GetAssetName(assetPath), assetType); }
// 检查并下载网络资源 public void CheckAndDownloadResource(List <string> assetPath, DownloadManager.DownloadFinishDelegate downloadAllOverCallBack) { #if UNITY_EDITOR if (!Settings.ActiveBundleMode) { OnAllDownloadOver(); if (downloadAllOverCallBack != null) { downloadAllOverCallBack(); } return; } #endif if (downlodingCount != 0) { Debug.LogError("已经有下载队列"); return; } // 检查所有 HashSet <string> toDownload = new HashSet <string> (); foreach (string _path in assetPath) { Debug.Log("_path:" + _path); string realPath = Assets.GetBundleName(_path); var allDependencies = Bundles.GetAllDependencies(realPath); HashSet <string> pathIncludeDependences = new HashSet <string> (); pathIncludeDependences.Add(realPath); foreach (string dependence in allDependencies) { pathIncludeDependences.Add(dependence); } foreach (string __path in pathIncludeDependences) { int _fileStatus; if (!filesStatus.TryGetValue(__path, out _fileStatus)) { filesStatus.Add(__path, FILE_STATUS_UNKOWN); toDownload.Add(__path); } else if (_fileStatus == FILE_STATUS_UNKOWN || _fileStatus == FILE_NOT_EXIST) { toDownload.Add(__path); } } } if (toDownload.Count == 0) { OnAllDownloadOver(); if (downloadAllOverCallBack != null) { downloadAllOverCallBack(); } } else { DownloadManager dm = DownloadManager.instance; dm.OnError += OnDownloadErr; dm.OnFinish += OnAllDownloadOver; if (downloadAllOverCallBack != null) { curDownloadAllOverCallback = downloadAllOverCallBack; dm.OnFinish += curDownloadAllOverCallback; } foreach (string realPath in toDownload) { string _path = Path.Combine(resUrlRoot, realPath); Debug.Log("下载文件:" + _path); dm.Push(new DownloadManager.Request(_path, OnFileDownloadOver, realPath)); } dm.Excute(); } }