{"id":2229,"date":"2021-03-25T07:59:00","date_gmt":"2021-03-24T23:59:00","guid":{"rendered":"http:\/\/www.u3d8.com\/?p=2229"},"modified":"2021-05-10T16:22:58","modified_gmt":"2021-05-10T08:22:58","slug":"addressable%e9%80%9a%e8%bf%87label%e8%8e%b7%e5%8f%96%e5%8c%85%e5%90%abkeys","status":"publish","type":"post","link":"http:\/\/www.u3d8.com\/?p=2229","title":{"rendered":"Addressable\u901a\u8fc7Label\u83b7\u53d6\u5305\u542bKeys"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>        \/\/\/ &lt;summary&gt;\n        \/\/\/ \u901a\u8fc7label\u83b7\u53d6keys\n        \/\/\/ &lt;\/summary&gt;\n        \/\/\/ &lt;returns&gt;&lt;\/returns&gt;\n        internal static IEnumerator GetKeysFromLabels(IEnumerable labels, Action&lt;List&lt;object&gt;&gt; keysCallback, Action&lt;AsyncOperationStatus&gt; statusCallback)\n        {\n            Debug.Log(\"\u3010\u901a\u8fc7Labels\u83b7\u53d6Keys\u3011\");\n            DateTime startTime = DateTime.Now;\n            AsyncOperationHandle&lt;IList&lt;IResourceLocation&gt;&gt; handle = UnityEngine.AddressableAssets.Addressables.LoadResourceLocationsAsync(labels, UnityEngine.AddressableAssets.Addressables.MergeMode.Union);\n            yield return handle;\n            if (handle.Status == AsyncOperationStatus.Succeeded)\n            {\n                Debug.Log(string.Format(\"\u3010\u901a\u8fc7Labels\u83b7\u53d6Keys\u6210\u529f\u3011\u6570\u91cf\uff1a{0} \u7528\u65f6\uff1a{1:0.00}S\", handle.Result.Count, (DateTime.Now - startTime).Seconds));\n                List&lt;object&gt; keys = new List&lt;object&gt;();\n                foreach (var item in handle.Result)\n                {\n                    keys.Add(item.PrimaryKey);\n                }\n                keysCallback?.Invoke(keys);\n                statusCallback?.Invoke(AsyncOperationStatus.Succeeded);\n            }\n            else\n            {\n                Debug.LogError(string.Format(\"\u3010\u8fc7Labels\u83b7\u53d6Keys\u5931\u8d25\u3011 \u7528\u65f6\uff1a{0:0.00}S\", (DateTime.Now - startTime).Seconds));\n                statusCallback?.Invoke(AsyncOperationStatus.Failed);\n            }\n            UnityEngine.AddressableAssets.Addressables.Release(handle);\n        }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2229"}],"collection":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2229"}],"version-history":[{"count":2,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2229\/revisions"}],"predecessor-version":[{"id":2241,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=\/wp\/v2\/posts\/2229\/revisions\/2241"}],"wp:attachment":[{"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2229"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.u3d8.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}