{"id":2265,"date":"2020-08-31T15:09:14","date_gmt":"2020-08-31T07:09:14","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=2265"},"modified":"2020-08-31T15:11:30","modified_gmt":"2020-08-31T07:11:30","slug":"unity%e6%96%87%e4%bb%b6%e7%9a%84%e4%b8%8b%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=2265","title":{"rendered":"[Unity]\u5927\u6587\u4ef6\u7684\u4e0b\u8f7d"},"content":{"rendered":"\n<p>\u5728Android\u673a\u4e0a\u6d4b\u8bd5\u66f4\u65b0\u5305\u6587\u4ef6\u4e0b\u8f7d\uff0c\u653e\u4e86\u4e00\u4e2a800M\u7684\u5305\u4f53\uff0c\u4e0b\u8f7d\u65f6\uff0cAppCrash\uff0cLogcat\u4e0a\u663e\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>08-31 12:05:02.641 11195 11227 E Unity   : Could not allocate memory: System out of memory!\n08-31 12:05:02.641 11195 11227 E Unity   : Trying to allocate: 902692864B with 16 alignment. MemoryLabel: WebRequest\n08-31 12:05:02.641 11195 11227 E Unity   : Allocation happened at: Line:75 in\n08-31 12:05:02.641 11195 11227 E Unity   : Memory overview\n08-31 12:05:02.641 11195 11227 E Unity   :\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_DEFAULT ] used: 24546420B | peak: 475860184B | reserved: 25104355B\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_TEMP_JOB ] used: 2980873B | peak: 0B | reserved: 7340032B\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_GAMEOBJECT ] used: 834054B | peak: 835462B | reserved: 838310B\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_GFX ] used: 147076B | peak: 3899375B | reserved: 148311B\n08-31 12:05:02.641 11195 11227 E Unity   : [ ALLOC_TEMP_THREAD ] used: 0B | peak: 0B | reserved: 3342336B\n0<\/code><\/pre>\n\n\n\n<p>\u63a8\u6d4b\u662f\u7531\u4e8eUnityWebRequest\u7533\u8bf7\u4e86\u8fc7\u5927\u7684\u5185\u5b58<\/p>\n\n\n\n<p>\u67e5\u9605\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>There are several types of DownloadHandlers:\nDownloadHandlerBuffer is used for simple data storage.\nDownloadHandlerFile is used for downloading and saving file to disk with low memory footprint.\nDownloadHandlerTexture is used for downloading images.\nDownloadHandlerAssetBundle is used for fetching AssetBundles.\nDownloadHandlerAudioClip is used for downloading audio files.\nDownloadHandlerMovieTexture is used for downloading video files. It is recommended that you use VideoPlayer for video download and movie playback since MovieTexture is deprecated.\nDownloadHandlerScript is a special class. On its own, it does nothing. However, this class can be inherited by a user-defined class. This class receives callbacks from the UnityWebRequest system, which can then be used to perform completely custom handling of data as it arrives from the network.<\/code><\/pre>\n\n\n\n<p>\u6240\u4ee5\u6539\u5199\u5927\u6587\u4ef6\u4e0b\u8f7d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var fileHandler = new DownloadHandlerFile(saveLocalFilename);\nfileHandler.removeFileOnAbort = true;\n\nUnityWebRequest request = UnityWebRequest.Get(url);\nrequest.downloadHandler = fileHandler;\nrequest.timeout = requestTimeout;\nrequest.SendWebRequest();<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Android\u673a\u4e0a\u6d4b\u8bd5\u66f4\u65b0\u5305\u6587\u4ef6\u4e0b\u8f7d\uff0c\u653e\u4e86\u4e00\u4e2a800M\u7684\u5305\u4f53\uff0c\u4e0b\u8f7d\u65f6\uff0cAppCrash\uff0cLogcat\u4e0a\u663e\u793a\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[18],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2265"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2265"}],"version-history":[{"count":3,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2265\/revisions"}],"predecessor-version":[{"id":2268,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2265\/revisions\/2268"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}