1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/// <summary> /// 通过label获取keys /// </summary> /// <returns></returns> internal static IEnumerator GetKeysFromLabels(IEnumerable labels, Action<List<object>> keysCallback, Action<AsyncOperationStatus> statusCallback) { Debug.Log("【通过Labels获取Keys】"); DateTime startTime = DateTime.Now; AsyncOperationHandle<IList<IResourceLocation>> handle = UnityEngine.AddressableAssets.Addressables.LoadResourceLocationsAsync(labels, UnityEngine.AddressableAssets.Addressables.MergeMode.Union); yield return handle; if (handle.Status == AsyncOperationStatus.Succeeded) { Debug.Log(string.Format("【通过Labels获取Keys成功】数量:{0} 用时:{1:0.00}S", handle.Result.Count, (DateTime.Now - startTime).Seconds)); List<object> keys = new List<object>(); foreach (var item in handle.Result) { keys.Add(item.PrimaryKey); } keysCallback?.Invoke(keys); statusCallback?.Invoke(AsyncOperationStatus.Succeeded); } else { Debug.LogError(string.Format("【过Labels获取Keys失败】 用时:{0:0.00}S", (DateTime.Now - startTime).Seconds)); statusCallback?.Invoke(AsyncOperationStatus.Failed); } UnityEngine.AddressableAssets.Addressables.Release(handle); } |
- 本文固定链接: http://www.u3d8.com/?p=2229
- 转载请注明: 网虫虫 在 u3d8.com 发表过
[…] Addressable通过Label获取包含Keys […]