{"id":98,"date":"2022-07-18T15:06:52","date_gmt":"2022-07-18T07:06:52","guid":{"rendered":"https:\/\/www.unitybundlemaster.com\/?p=98"},"modified":"2022-07-18T17:54:32","modified_gmt":"2022-07-18T09:54:32","slug":"%e7%ac%ac%e4%b8%80%e7%ab%a0-%e4%ba%86%e8%a7%a3unity%e7%9b%ae%e5%bd%95%e4%b8%8e%e5%8a%a0%e8%bd%bdapi","status":"publish","type":"post","link":"https:\/\/www.unitybundlemaster.com\/?p=98","title":{"rendered":"\u7b2c\u4e00\u7ae0 \u4e86\u89e3Unity\u76ee\u5f55\u4e0e\u52a0\u8f7d\u65b9\u5f0f"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">1. <em>Resources\uff0cStreamingAssets \u548c PersistentDataPath<\/em><\/h4>\n\n\n\n<p>\u5728\u5e8f\u8a00\u4e2d\u5df2\u7ecf\u63d0\u5230\u8bf4 Resources \u53ef\u4ee5\u7528\u6765\u5b58\u653e\u8d44\u6e90\u5e76\u63d0\u51fa\u4e00\u4e9b\u7f3a\u9677\uff0c\u4f46Resources\u4f9d\u7136\u8fd8\u662f\u9700\u8981\u7528\u5230\u7684\uff0c\u4e3b\u8981\u662f\u7528\u6765\u5b58\u653e\u4e00\u4e9b\u4e0d\u9700\u8981\u70ed\u66f4\u7684\u7279\u6b8a\u6587\u4ef6\uff0c\u901a\u5e38\u662f\u4e00\u4e9b\u914d\u7f6e\u6587\u4ef6\uff0c\u6216\u8005\u53ef\u80fd\u662f\u6e38\u620f\u7684logo\u4ee5\u53ca\u542f\u52a8\u753b\u9762\u4e4b\u7c7b\u7684\uff0c\u8fd9\u4e9b\u8d44\u6e90\u5f88\u5c0f\uff0c\u800c\u4e14\u4e5f\u4e0d\u9700\u8981\u66f4\u65b0\uff0c\u6240\u4ee5\u53ef\u4ee5\u653e\u5230 Resources \u6587\u4ef6\u5939\u4e0b\u3002\u5728\u6253\u5305\u7684\u65f6\u5019\uff0cUnity\u4f1a\u628a\u5de5\u7a0b\u4e0b\u6240\u6709 Resources \u6587\u4ef6\u5939\u8fdb\u884c\u5408\u5e76\u538b\u7f29\u5728\u4e00\u8d77\u3002<\/p>\n\n\n\n<p>StreamingAssets \u548c PersistentDataPath\uff0c\u8fd9\u4e24\u4e2a\u6587\u4ef6\u5939\u90fd\u662f\u5b58\u653e\u7684\u539f\u751f\u8d44\u6e90\uff0c\u4e5f\u5c31\u662f\u6587\u4ef6\u5939\u4e0b\u6709\u4ec0\u4e48\uff0c\u6253\u5305\u5b8c\u6210\u540e\u91cc\u9762\u5c31\u662f\u4ec0\u4e48\uff0c\u5e76\u4e0d\u4f1a\u5bf9\u6587\u4ef6\u8fdb\u884c\u66f4\u6539\uff0c\u4f46\u5728PC\u5e73\u53f0\u4e0e\u79fb\u52a8\u5e73\u53f0\u4e0a\uff0cStreamingAssets \u662f\u6709\u6240\u533a\u522b\u7684\u3002\u5728PC\u5e73\u53f0\u4e0a\u5982 Windows\uff0cStreamingAssets \u53ef\u8bfb\u53ef\u5199\uff0c\u800c\u5728\u79fb\u52a8\u5e73\u53f0\u4e0a\u5982 Android\uff0cStreamingAssets \u5c31\u53ea\u6709\u53ef\u8bfb\u6743\u9650\u4e86\uff0c\u5e76\u4e14\u4e0d\u53ef\u4ee5\u76f4\u63a5\u7528C#\u7684IO\u7c7b\u8fdb\u884c\u52a0\u8f7d\uff0c\u5982 FileStream \u7c7b\uff0c\u4e5f\u6ca1\u6709\u529e\u6cd5\u4f7f\u7528C#\u7684 File.Exists \u5224\u65ad\u8d44\u6e90\u662f\u5426\u5b58\u5728\uff0c\u60f3\u8981\u8bfb\u53d6 StreamingAssets \u4e0b\u7684\u8d44\u6e90\uff0c\u53ef\u4ee5\u7528 UnityWebRequest \u7684\u65b9\u5f0f\u53bb\u5f02\u6b65\u52a0\u8f7d\u8d44\u6e90\uff0c\u5982\u679c\u8d44\u6e90\u662f AssetBundle\uff0c\u4e5f\u53ef\u4ee5\u7528 AssetBundle.LoadFromFile \u6765\u52a0\u8f7d\u3002BundleMaster \u5c06 LocalBundlePath \u9ed8\u8ba4\u8bbe\u7f6e\u4e3a StreamingAssets\uff0c\u7528\u6765\u5b58\u653e\u9996\u5305\u8d44\u6e90\uff0c\u800c\u4e4b\u540e\u66f4\u65b0\u7684\u5185\u5bb9\uff0c\u4f1a\u5c06\u66f4\u65b0\u90e8\u5206\u5b58\u653e\u5728 PersistentDataPath \u76ee\u5f55\u4e0b\u3002\uff08Tips. \u4ec0\u4e48\u662f\u9996\u5305\u8d44\u6e90\uff1f \u4e00\u4e9b\u9879\u76ee\u8d44\u6e90\u5185\u5bb9\u5e76\u4e0d\u5927\uff0c\u5e0c\u671b\u5c06\u8d44\u6e90\u653e\u5728\u5305\u4f53\u5185\u4e5f\u5c31\u662f StreamingAssets \u4e0b\uff0c\u8fd9\u4efd\u8d44\u6e90\u5c31\u662f\u9996\u5305\u8d44\u6e90\u3002\uff09<\/p>\n\n\n\n<p>PersistentDataPath \u76ee\u5f55\u5728\u79fb\u52a8\u5e73\u53f0\u4e0b\u6ca1\u6709\u9650\u5236\uff0c\u65e2\u53ef\u8bfb\u4e5f\u53ef\u5199\uff0c\u5e76\u4e14\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528C#\u7684IO\u7c7b\u3002BundleMaster \u5c06\u66f4\u65b0\u76ee\u5f55\u4e5f\u5c31\u662f HotfixPath \u9ed8\u8ba4\u8bbe\u7f6e\u4e3a PersistentDataPath \uff0c\u4f46\u8981\u6ce8\u610f\u7684\u662f PersistentDataPath \u76ee\u5f55\u5728 Windows \u4e0b \u5728C\u76d8\uff0c\u56e0\u6b64\u4f7f\u7528BundleMaster\u7684\u65f6\u5019\u63a8\u8350\u5728\u5f00\u53d1\u9636\u6bb5\u7f16\u8f91\u5668\u4e0b\u7684\u65f6\u5019\uff0c\u5c06\u66f4\u65b0\u76ee\u5f55\u4e5f\u5c31\u662f HotfixPath&nbsp;\u91cd\u65b0\u6620\u5c04\u4e3a\u5176\u5b83\u5730\u65b9\u3002<\/p>\n\n\n\n<p>\u6253\u5305\u7684\u65f6\u5019\u975e Resources \u548c StreamingAssets \u4e0b\u7684\u8d44\u6e90\u90fd\u4f1a\u88ab\u4e22\u5f03\u6389\uff0c\u6211\u4eec\u6b63\u597d\u53ef\u4ee5\u5229\u7528\u8fd9\u4e00\u7279\u6027\uff0c\u521b\u5efa\u4e00\u4e2a\u5176\u5b83\u6587\u4ef6\u5939\u7528\u4e8e\u5b58\u653e\u6211\u4eec\u7684\u8d44\u6e90\uff0c\u800c\u6700\u540e\u4f1a\u5c06\u8d44\u6e90\u6784\u5efa\u6210 AssetBundle\uff0c\u6211\u4eec\u53ea\u9700\u8981 AssetBundle \u5728\u5305\u4f53\u91cc\u5373\u53ef\uff0c\u8d44\u6e90\u6b63\u597d\u53ef\u4ee5\u5728\u6253\u5305\u7684\u65f6\u5019\u4e22\u5f03\u6389\uff0c\u4e0d\u4f1a\u5728\u5305\u91cc\u5360\u7528\u989d\u5916\u7684\u7a7a\u95f4\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. <em>\u52a0\u8f7d\u8d44\u6e90\u7684\u65b9\u5f0f<\/em><\/h4>\n\n\n\n<p>\u5bf9\u4e8e\u52a0\u8f7d\u4f7f\u7528\u5230\u7684API\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\uff0c\u53ef\u4ee5\u67e5\u9605Unity\u7684\u5b98\u65b9\u6587\u6863\u3002Resources \u53ea\u53ef\u4ee5 \u52a0\u8f7dResources \u6587\u4ef6\u5939\u4e0b\u7684\u8d44\u6e90\uff0c\u53ef\u4ee5\u4e0d\u586b\u8d44\u6e90\u540e\u7f00\u3002BundleMaster \u4f7f\u7528\u7684\u662f LoadFromMemory \u901a\u8fc7 byte[] \u52a0\u8f7d AssetBundle \uff0c\u6bd4\u8f83\u7075\u6d3b\u3002AssetDatabase.LoadAssetAtPath \u662f\u53ea\u6709\u5728\u7f16\u8f91\u5668\u4e0b\u624d\u53ef\u4ee5\u4f7f\u7528\u7684\u52a0\u8f7dAPI\uff0c\u5b83\u53ef\u4ee5\u52a0\u8f7d\u6240\u6709\u8def\u5f84\u4e0b\u7684\u8d44\u6e90\uff0c\u5e76\u4e14\u4e0d\u7ba1Unity\u662f\u5426\u662f\u8fd0\u884c\u65f6\u90fd\u53ef\u4ee5\u52a0\u8f7d\uff0c\u4f46\u5b83\u53ea\u80fd\u540c\u6b65\u52a0\u8f7d\u6ca1\u6709\u529e\u6cd5\u8fdb\u884c\u5f02\u6b65\u3002<\/p>\n\n\n\n<p>\u5728 BundleMaster \u4e2d\u63d0\u4f9b\u4e86\u4e09\u79cd\u8fd0\u884c\u6a21\u5f0f\u3002\u5206\u522b\u662f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Develop<\/li><li>Local<\/li><li>Build<\/li><\/ol>\n\n\n\n<p>\u5176\u4e2d Develop \u6a21\u5f0f\u4e0b\u6240\u6709\u52a0\u8f7dAPI\u90fd\u662f\u8c03\u7528\u7684 AssetDatabase.LoadAssetAtPath \uff0c\u8fd9\u6837\u5728\u5f00\u53d1\u9636\u6bb5\u4e2d\u4e0d\u9700\u8981\u6784\u5efa AssetBundle \u5305\uff0c\u975e\u5e38\u65b9\u4fbf\uff0c\u4f46\u4e0e\u4e4b\u76f8\u5bf9\u7684\u6240\u6709\u5f02\u6b65\u52a0\u8f7d\u63a5\u53e3\u5728 Develop \u4e0b\u90fd\u662f\u540c\u6b65\u6267\u884c\u7684\u3002Local \u6a21\u5f0f\u5219\u662f\u8df3\u8fc7\u68c0\u67e5\u66f4\u65b0\u7684\u6d41\u7a0b\uff0c\u76f4\u63a5\u4f7f\u7528 LocalBundlePath \u4e0b\u7684\u8d44\u6e90\u3002Build \u6a21\u5f0f\u5219\u662f\u6b63\u5e38\u68c0\u67e5\u66f4\u65b0\uff0c\u5e76\u4e14\u5c06\u66f4\u65b0\u7684\u90e8\u5206\u653e\u5728 HotfixPath\u4e0b\uff0c\u4f1a\u4f18\u5148\u52a0\u8f7dHotfixPath\u4e0b\u7684\u8d44\u6e90\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>91\u7126\u5148\u751f<\/p><cite>2022\/07\/18<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>1. Resources\uff0cStreamingAssets \u548c PersistentDataPath \u5728\u5e8f\u8a00\u4e2d\u5df2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-assetbundle-"],"_links":{"self":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98"}],"version-history":[{"count":17,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}