private async void QueryAssetHash(Dictionary <string, StorageManager.DownloadAssetInfo> infoList, System.Action <Dictionary <string, StorageManager.DownloadAssetInfo> > OnQueryFinish) { // 先连接server,检查所有Asset对应当前平台的文件Hash,并回填数据 string[] assetIds = new string[infoList.Count]; int index = 0; foreach (DownloadAssetInfo info in infoList.Values) { assetIds[index] = info.id; index++; } try { List <Asset> queryRs = await assetAPI.ListAssetsByIds(assetIds, currentPlatform); Debug.Log("Query find [" + queryRs.Count + "] assets!"); for (int i = 0; i < queryRs.Count; i++) { Asset asset = queryRs[i]; if (infoList.ContainsKey(asset.id)) { for (int j = 0; j < asset.contents.Length; j++) { AssetContent content = asset.contents[j]; if (content.platform == currentPlatform) { DownloadAssetInfo info = infoList[asset.id]; info.hash = content.bundleHash; Debug.Log("Fill Hash for asset [" + asset.id + "]"); } } } } } catch (System.Exception e) { Debug.LogError(e); err = e.ToString(); } MEHoloEntrance.Instance.Dispatch((param) => { if (OnQueryFinish != null) { OnQueryFinish(infoList); } }); }
private async void QueryAssetHash(Dictionary <string, LibraryManager.DownloadAssetInfo> infoList, System.Action <Dictionary <string, LibraryManager.DownloadAssetInfo> > OnQueryFinish) { // 先连接server,检查所有Asset对应当前平台的文件Hash,并回填数据 List <string> assetIds = new List <string>(); int index = 0; foreach (DownloadAssetInfo info in infoList.Values) { assetIds.Add(info.id); index++; } DcsLibraryEntityType currentPlatform; #if UNITY_STANDALONE_WIN || UNITY_EDITOR currentPlatform = DcsLibraryEntityType.EntityTypeAssetPC; #elif UNITY_IOS currentPlatform = DcsLibraryEntityType.EntityTypeAssetIOS; #elif UNITY_ANDROID currentPlatform = DcsLibraryEntityType.EntityTypeAssetAndroid; #elif UNITY_WSA currentPlatform = DcsLibraryEntityType.EntityTypeAssetUWP; #endif LibraryApi libraryApi = new LibraryApi("https://library." + AccountManager.Instance.RegionCode + ".datamesh.com"); try { List <DcsLibraryResource> queryRs = await libraryApi.ListResourcesByIds( AccountManager.Instance.UserCredential.AccessKey, AccountManager.Instance.UserCredential.AccessSecret, assetIds, currentPlatform); Debug.Log("Query find [" + queryRs.Count + "] assets!"); for (int i = 0; i < queryRs.Count; i++) { DcsLibraryResource resource = queryRs[i]; Debug.Log("entitis length=" + resource.Entities.Length); for (int j = 0; j < resource.Entities.Length; j++) { DcsLibraryEntity asset = resource.Entities[j]; if (asset.EntityType == currentPlatform) { if (infoList.ContainsKey(resource.Id)) { DownloadAssetInfo info = infoList[resource.Id]; info.hash = asset.Id; Debug.Log("Fill Hash for asset [" + resource.Id + "]=[" + asset.Id + "]"); } } } } } catch (System.Exception e) { Debug.LogError(e); err = e.ToString(); } MEHoloEntrance.Instance.Dispatch((param) => { if (OnQueryFinish != null) { OnQueryFinish(infoList); } }); }