{"id":118,"date":"2022-07-19T12:13:49","date_gmt":"2022-07-19T04:13:49","guid":{"rendered":"https:\/\/www.unitybundlemaster.com\/?p=118"},"modified":"2022-08-16T15:06:04","modified_gmt":"2022-08-16T07:06:04","slug":"%e7%ac%ac%e4%ba%8c%e7%ab%a0-%e4%ba%86%e8%a7%a3assetbundle%e5%8d%a0%e7%94%a8%e5%86%85%e5%ad%98","status":"publish","type":"post","link":"https:\/\/www.unitybundlemaster.com\/?p=118","title":{"rendered":"\u7b2c\u4e8c\u7ae0 \u4e86\u89e3AssetBundle\u7684\u751f\u547d\u5468\u671f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5f53\u6211\u4eec\u6784\u5efa\u597d\u4e00\u4e2aAssetBundle\u4e4b\u540e\uff0c\u5f53\u7136\u662f\u8981\u52a0\u8f7d\u5b83\uff0cUnity \u63d0\u4f9b\u4e86\u4e09\u79cd\u52a0\u8f7d AssetBundle\u7684API\uff0c\u5206\u522b\u662f :<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>AssetBundle.LoadFromMemory \u901a\u8fc7 byte[] \u6570\u7ec4\u52a0\u8f7d\uff0c\u65e0\u8bba\u7528\u4ec0\u4e48\u65b9\u6cd5\u53ea\u8981\u62ff\u5230\u8d44\u6e90\u7684 byte[] \u6570\u636e\u5c31\u53ef\u4ee5\u52a0\u8f7d\uff0c\u6bd4\u8f83\u7075\u6d3b\uff0cBundleMaster \u5728\u4f7f\u7528\u5f02\u6216\u52a0\u5bc6\u7684\u65f6\u5019\u7528\u8fd9\u79cd\u65b9\u5f0f\u3002<\/li><li> AssetBundle.LoadFromFile \u901a\u8fc7\u8def\u5f84\u52a0\u8f7d\uff0c\u597d\u5904\u662f\u53ef\u4ee5\u76f4\u63a5\u52a0\u8f7d StreamingAssets \u4e0b\u7684\u8d44\u6e90\uff0c\u5e76\u4e14\u4e0d\u4f1a\u50cf LoadFromMemory \u90a3\u6837\u5360\u7528\u989d\u5916\u7684\u5806\u5185\u5b58(LZMA\u538b\u7f29\u7684\u60c5\u51b5\u4e0b\u4e0d\u751f\u6548)\uff0cBundleMaster \u9ed8\u8ba4\u4f7f\u7528\u6b64\u6a21\u5f0f\u3002<\/li><li>AssetBundle.LoadFromStream \u901a\u8fc7\u6587\u4ef6\u6d41\u52a0\u8f7d\uff0c\u9650\u5236\u8f83\u591a\uff0c\u4f46\u53ef\u4ee5\u81ea\u5df1\u8bbe\u5b9a\u00a0Unity \u52a0\u8f7d\u6570\u636e\u65f6\u4f7f\u7528\u7684\u8bfb\u53d6\u7f13\u51b2\u533a\u5927\u5c0f\u4ece\u800c\u63d0\u5347\u52a0\u8f7d\u6027\u80fd\uff0c\u80fd\u4f18\u5316\u4e00\u70b9\u70b9\u6027\u80fd\uff0c\u4e0d\u8fc7\u4e00\u822c\u4e0d\u7528\u3002<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u5c31\u83b7\u5f97\u4e86\u4e00\u4e2a AssetBundle \u5bf9\u8c61\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u8fd9\u4e2a\u5bf9\u8c61\u91cc\u83b7\u53d6\u6211\u4eec\u60f3\u8981\u7684\u8d44\u6e90\uff0c\u5982\u679c\u8fd9\u4e2a\u8d44\u6e90\u662f GameObject\uff0c\u5219\u53ef\u4ee5\u5c06\u52a0\u8f7d\u51fa\u6765\u7684\u8d44\u6e90\u5b9e\u4f8b\u5316\uff0c\u5c31\u5f97\u5230\u4e86\u6e38\u620f\u4e2d\u5177\u4f53\u7684\u7269\u4f53\uff0c\u5982\u679c\u9700\u8981\u591a\u4e2a\u7269\u4f53\u4e5f\u53ef\u4ee5\u5b9e\u4f8b\u5316\u591a\u6b21\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u60f3\u8981\u5378\u8f7d\u67d0\u4e2a\u8d44\u6e90\uff0c\u9700\u8981\u5148\u5c06\u6240\u6709\u5b9e\u4f8b\u5316\u51fa\u6765\u7684\u7269\u4f53\u6e05\u9664\uff0c\u7136\u540e\u5bf9 AssetBundle \u5bf9\u8c61\u8c03\u7528 Unload\uff0c\u4f46\u662f Unload \u6709\u4e00\u4e2a\u53c2\u6570 bool unloadAllLoadedObjects\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f53 unloadAllLoadedObjects \u4e3a true \u7684\u65f6\u5019\uff0c\u5378\u8f7d\u4f1a\u5c06\u8fd9\u4e2a AssetBundle \u52a0\u8f7d\u51fa\u7684\u6240\u6709\u8d44\u6e90\u90fd\u7ed9\u5378\u8f7d\u6389\uff0cBundleMaster \u4f7f\u7528\u7684\u5c31\u662f\u8fd9\u4e2a\u3002<\/li><li>\u5f53 unloadAllLoadedObjects \u4e3a false\u7684\u65f6\u5019\uff0c\u5378\u8f7d AssetBundle \u53ea\u4f1a\u5378\u8f7d\u539f\u59cb\u6570\u636e\u548c\u52a0\u8f7d\u51fa\u6765\u6ca1\u6709\u5f15\u7528\u7684\u8d44\u6e90\uff0c\u800c\u62e5\u6709\u5f15\u7528\u7684\u8d44\u6e90\u5e76\u4e0d\u4f1a\u5378\u8f7d\uff0c\u5982\u679c\u60f3\u8981\u5378\u8f7d\u6389\u8fd9\u7c7b\u8d44\u9700\u8981\u5c06\u5f15\u7528\u53d6\u6d88\u5e76\u4e14\u624b\u52a8\u8c03\u7528 Resources.UnloadUnusedAssets\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f7f\u7528 Unload(false) \u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5728\u8d44\u6e90\u88ab\u4ece AssetBundle \u4e2d\u52a0\u8f7d\u51fa\u6765\u7684\u65f6\u5019\u5c31\u5c06 AssetBundle \u5378\u8f7d\uff0c\u53ef\u4ee5\u8282\u7701\u4e00\u70b9\u70b9\u5185\u5b58\u7684\u4f7f\u7528\uff0c\u4f46\u662f\u5982\u679c\u4e00\u4e2a AssetBundle \u5f53\u4e2d\u62e5\u6709\u5f88\u591a\u8d44\u6e90\uff0c\u518d\u52a0\u8f7d\u8fd9\u4e2a AssetBundle \u4e2d\u5176\u5b83\u8d44\u6e90\u7684\u65f6\u5019\u5c31\u53c8\u9700\u8981\u5c06 AssetBundle \u91cd\u65b0\u52a0\u8f7d\u51fa\u6765\uff0c\u6d6a\u8d39\u6389\u7684\u6027\u80fd\u4e0e\u7701\u4e0b\u7684\u90a3\u4e00\u70b9\u70b9\u5185\u5b58\u76f8\u6bd4\u5f97\u4e0d\u507f\u5931\uff0c\u66f4\u4f55\u51b5 AssetBundle \u90fd\u662f\u7ecf\u8fc7\u9ad8\u5ea6\u538b\u7f29\u7684\uff0c\u672c\u6765\u5360\u7528\u5185\u5b58\u5c31\u4e0d\u5927\uff0c\u6240\u4ee5\u7efc\u5408\u6765\u770b\u8fd8\u662f\u4f7f\u7528 Unload(true) \u7684\u673a\u5236\u6bd4\u8f83\u597d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u80fd\u6709\u670b\u53cb\u5bf9\u4e0a\u9762\u7684\u8fc7\u7a0b\u4e2d\u8bf8\u5982 AssetBundle \u548c AssetBundle\u52a0\u8f7d\u51fa\u7684\u8d44\u6e90\u6709\u6240\u7591\u95ee\uff0c\u6b22\u8fce\u770b\u4e0b\u4e00\u7ae0\uff0c\u4f1a\u7740\u91cd\u5206\u6790\u8fd9\u91cc\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>91\u7126\u5148\u751f<\/em><\/p><cite>2022\/07\/19<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u6211\u4eec\u6784\u5efa\u597d\u4e00\u4e2aAssetBundle\u4e4b\u540e\uff0c\u5f53\u7136\u662f\u8981\u52a0\u8f7d\u5b83\uff0cUnity \u63d0\u4f9b\u4e86\u4e09\u79cd\u52a0\u8f7d AssetBundle [&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-118","post","type-post","status-publish","format-standard","hentry","category-assetbundle-"],"_links":{"self":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/118","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=118"}],"version-history":[{"count":11,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":182,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/182"}],"wp:attachment":[{"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unitybundlemaster.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}