{"id":1422,"date":"2014-02-19T19:13:47","date_gmt":"2014-02-19T11:13:47","guid":{"rendered":"http:\/\/blog.1vr.cn\/?p=1422"},"modified":"2017-05-30T23:29:17","modified_gmt":"2017-05-30T15:29:17","slug":"unity-2d%e5%85%a5%e9%97%a8%e5%9f%ba%e7%a1%80%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/1vr.cn\/?p=1422","title":{"rendered":"Unity 2D\u5165\u95e8\u57fa\u7840\u6559\u7a0b"},"content":{"rendered":"<p>\u5199\u5728\u524d\u9762\u7684\u8bdd:\u8f6c\u8f7d\u80af\u5b9a\u4f1a\u7559\u539f\u6587\u94fe\u63a5,\u4f5c\u8005\u7684\u7f72\u540d,\u8fd9\u662f\u6bcb\u5eb8\u7f6e\u7591\u7684.\u800c\u6211\u7684\u4e60\u60ef\u662f\u7ffb\u8bd1\u5b8c\u6587\u5b57\u540e\u4f1a\u901a\u77e5\u5230\u539f\u4f5c\u8005\u5e76\u5206\u4eab\u7ed9\u539f\u4f5c\u8005\u7ffb\u8bd1\u540e\u7684\u7248\u672c,\u6bd4\u5982\u50cf\u6211\u505aEZGUI\u7684\u5e2e\u52a9\u6587\u6863\u7684\u65f6\u5019,\u4f5c\u8005\u7279\u610f\u5c06\u5176\u5e2e\u52a9\u6587\u6863\u7684&#8221;\u6e90\u5de5\u7a0b&#8221;\u7ed9\u6211\u53d1\u6765\u4e86.NGUI\u7684\u4f5c\u8005\u4e5f\u5f00\u5fc3\u7684\u628a\u6211\u7684\u8bd1\u6587\u94fe\u63a5\u653e\u5230\u4e86\u4ed6\u5b98\u7f51\u505a\u4e3aNGUI\u4e2d\u6587\u7248\u6559\u7a0b,\u6211\u4eec\u90fd\u662f\u505a\u7740\u5f00\u5fc3\u7684\u4e8b,\u800c\u8fd9\u4e2a2D\u6559\u7a0b\u539f\u4f5c\u8005\u504f\u504f\u8981\u6211\u628a\u535a\u5ba2\u4e0a\u8fd9\u7bc7\u6559\u7a0b\u5220\u9664\u6389,\u8bf4\u4e0d\u6388\u6743\u7ed9\u9664\u4e86\u4ed6\u4eec\u81ea\u5df1\u7f51\u7ad9\u5916\u7684\u7b2c\u4e09\u65b9\u7f51\u7ad9\u53d1\u8868,\u8981\u662f\u613f\u610f\u7684\u8bdd\u4e5f\u53ef\u4ee5\u52a0\u5165\u4ed6\u4eec\u7684\u7ffb\u8bd1\u7ec4,\u52a0\u5165\u540e\u624d\u53ef\u4ee5\u628a\u6211\u7ffb\u8bd1\u7684\u8fd9\u4e2a\u6559\u7a0b\u653e\u5230\u4ed6\u4eec\u7684\u7f51\u7ad9\u4e0a,\u4ec5\u6b64\u800c\u5df2.\u867d\u7136\u8001\u5916\u7248\u6743\u610f\u8bc6\u6d53\u539a,\u4f46\u6211\u8fd8\u662f\u89c9\u5f97\u4ed6\u4eec\u8fd9\u662f\u5f88\u86cb\u75bc\u7684\u884c\u4e3a,\u6211\u51b3\u5b9a\u9009\u62e9\u65e0\u89c6\u4ed6,\u5e76\u4e14\u4fdd\u7559\u8fd9\u7bc7\u6559\u7a0b,\u9000\u4e00\u6b65\u8bb2\u60f9\u6025\u4e86\u6211\u628a\u622a\u56fe\u90fd\u6362\u6210\u6211\u81ea\u5df1\u7684,\u6539\u4e00\u6539\u6587\u5b57,\u5e72\u8106\u53d8\u6210\u539f\u521b\u6559\u7a0b\u597d\u4e86&#8230;..\u5475\u5475\u5475&#8230;.<\/p>\n<p>==================================\u534e\u4e3d\u7684\u5206\u5272\u7ebf==================================<\/p>\n<p>\u5982\u679c\u7528\u4ee5\u524d\u7248\u672c\u7684Unity\u505a2D\u6e38\u620f,\u867d\u7136\u80fd\u505a,\u4f46\u662f\u8981\u8d39\u5f88\u591a\u5468\u6298.<br \/>\n\u6bd4\u5982\u4f60\u53ef\u4ee5\u5c06\u4e00\u5f20\u7eb9\u7406\u8d4b\u4e88\u4e00\u4e2a&#8221;\u9762\u7247&#8221;\u7f51\u683c,\u7136\u540e\u7528\u811a\u672c\u63a7\u5236\u5b83\u7684\u52a8\u753b\u8c03\u6574\u5b83\u7684\u4f4d\u79fb.\u5982\u679c\u4f60\u8981\u4f7f\u7528\u7269\u7406\u5f15\u64ce,\u90a3\u4e48\u8fd8\u8981\u5c06\u8fd9\u4e2aObeject\u5904\u74063D\u7684,\u6240\u4ee5\u4f60\u8fd8\u8981\u786e\u4fdd\u4f60\u7684Object\u8981\u6709\u8db3\u591f\u7684\u6df1\u5ea6\u4ee5\u786e\u4fdd\u4ed6\u4eec\u5728\u5176\u5b83\u8f74\u5411\u4e0a\u4e0d\u8d77\u51b2\u7a81.\u6216\u8005\u4f60\u9009\u7528\u4e00\u4e2a\u7b2c\u4e09\u65b9\u63d2\u4ef6,\u59822D Toolkit\u6216\u8005Orthello 2D Framework,\u4ed6\u4eec\u6709\u7740\u5f3a\u5927\u7684\u529f\u80fd,\u4f46\u540c\u6837\u9700\u8981\u4f60\u53bb\u505a\u4e00\u4e9b\u7ea6\u675f\u5de5\u4f5c.<br \/>\n\u5f53\u4e0a\u9762\u8fd9\u4e9b\u4f60\u4ecd\u7136\u53ef\u4ee5\u9009\u7528\u4e0a\u9762\u8fd9\u4e9b\u65b9\u6cd5\u7684\u65f6\u5019,Unity4.3\u589e\u52a0\u4e86\u539f\u751f\u76842D\u5f00\u53d1\u73af\u5883,\u8ba9\u6211\u4eec\u4e00\u63a2\u7a76\u7adf\u5427.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1463\" rel=\"attachment wp-att-1463\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1463 aligncenter\" alt=\"overview_pic\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/overview_pic.png\" width=\"250\" height=\"250\" srcset=\"\/wp-content\/uploads\/2014\/02\/overview_pic.png 250w, \/wp-content\/uploads\/2014\/02\/overview_pic-150x150.png 150w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>\u8fd9\u4e2a\u6559\u7a0b\u5c06\u5e26\u4f60\u63a2\u7d22Unity\u76842D\u5de5\u5177,\u6559\u7a0b\u5c06\u5f15\u5bfc\u4f60\u505a\u4e00\u4e2a\u4e3b\u9898\u4e3a\u50f5\u5c38\u7684iOS\u6e38\u620f.\u6559\u7a0b\u91cd\u70b9\u5728\u4e8e\u4e00\u4e2a\u65b0\u7684\u8d44\u6e90\u7c7b\u578b-&#8220;Sprite&#8221;,\u4f60\u5c06\u5b66\u5230\u6240\u6709\u5173\u4e8eSprite\u77e5\u8bc6,\u5728\u540e\u7eed\u7684\u6559\u7a0b\u91cc\u4f60\u5c06\u5b66\u4f1a\u5982\u4f55\u901a\u8fc7Unity\u7684\u52a8\u753b\u7cfb\u7edf\u63a7\u5236\u52a8\u753b,\u4ee5\u53ca\u7528\u5230Untiy\u76842D\u7269\u7406\u5f15\u64ce\u7684\u652f\u6301.<\/p>\n<p><!--more--><\/p>\n<p>\u4e0a\u9762\u662f\u4e2a\u6559\u7a0b\u6982\u8ff0,\u4e0b\u9762\u8ba9\u6211\u4eec\u4e00\u6b65\u4e00\u6b65\u6765\u5427.<\/p>\n<p><span style=\"text-decoration: underline;\">\u6ce8:\u672c\u6559\u7a0b\u5047\u5b9a\u4f60\u6709\u4e00\u4e9bUnity\u7684\u4f7f\u7528\u7ecf\u9a8c,\u77e5\u9053\u4e00\u4e9b\u57fa\u672c\u77e5\u8bc6,\u4e86\u89e3Unity\u7684\u754c\u9762,\u6e38\u620f\u5bf9\u8c61\u548c\u7ec4\u4ef6\u7b49\u64cd\u4f5c,\u6bd4\u5982\u4f60\u77e5\u9053&#8221;\u8981\u6dfb\u52a0\u4e00\u4e2a&#8221;\u732b&#8221;\u5230\u573a\u666f\u91cc\u9700\u8981\u4eceProject\u62fd\u5230Hierarchy\u91cc&#8221;.<\/span><br \/>\n<span style=\"text-decoration: underline;\"> \u5982\u679c\u4f60\u770b\u4e0d\u61c2\u4e0a\u9762\u8fd9\u4e2a,\u90a3\u4e48\u4f60\u9700\u8981\u4e00\u4e2a\u6559\u7a0b\u5165\u95e8\u518d\u6765\u770b\u73b0\u5728\u8fd9\u4e2a2D\u6559\u7a0b.<\/span><\/p>\n<p>\u6700\u540e\u8981\u6ce8\u610f,\u672c\u6559\u7a0b\u662f\u5728OS X\u7cfb\u7edf\u4e0b\u64cd\u4f5c\u7684,\u7136\u800c\u5982\u679c\u4f60\u5728Windows\u4e0b\u4e5f\u4e0d\u7528\u62c5\u5fc3,Unity\u5728Windows\u4e0a\u548cOS X\u4e0b\u5927\u591a\u6570\u6307\u4ee4\u90fd\u662f\u4e00\u6837\u7684,\u4f1a\u6709\u4e00\u4e9b\u5c0f\u7684\u5dee\u5f02(\u5982\u4f7f\u7528Windows\u8d44\u6e90\u7ba1\u7406\u5668\u53d6\u4ee3Finder),\u6216\u8005\u5e72\u8106\u76f4\u63a5\u7528OS X \u7cfb\u7edf.<\/p>\n<p><span style=\"color: #000000;\"><strong>\u5f00\u59cb:<\/strong><\/span><\/p>\n<p>Unity\u57284.3\u4e2d\u52a0\u5165\u4e86\u539f\u751f\u76842D\u5de5\u5177(\u4e13\u4e1a\u7248\u548c\u514d\u8d39\u7248\u90fd\u5e26),\u6240\u4ee5\u4f60\u8981\u786e\u4fdd\u4f60\u5b89\u88c5\u7684\u6700\u65b0\u7248,\u53ef\u4ee5\u4ece\u5b98\u7f51\u4e0b\u8f7d\u5230.<\/p>\n<p>\u4f60\u8fd8\u9700\u8981\u4e00\u4e9b\u7f8e\u672f\u8d44\u6e90\u4e3a\u8fd9\u4e2a2D\u6e38\u620f,\u5e78\u8fd0\u7684\u662fMike Berg(<a href=\"http:\/\/weheartgames.com\/\">http:\/\/weheartgames.com\/<\/a>)\u5df2\u7ecf\u505a\u4e86\u4e00\u4e9b\u5f88\u9177\u7684\u56fe\u7247\u8d44\u6e90,\u53ef\u4ee5\u4ece\u8fd9\u91cc\u4e0b\u8f7d\u89e3\u538b\u4f7f\u7528:<a href=\"http:\/\/cdn4.raywenderlich.com\/wp-content\/uploads\/2013\/12\/ZombieConga-Part1-Resources.zip\">http:\/\/cdn4.raywenderlich.com\/wp-content\/uploads\/2013\/12\/ZombieConga-Part1-Resources.zip<\/a><\/p>\n<p><span style=\"text-decoration: underline;\">\u6ce8:\u4f60\u53ef\u4ee5\u5728\u5176\u4ed6\u6e38\u620f\u91cc\u4f7f\u7528\u6216\u4fee\u6539\u672c\u6559\u7a0b\u91cc\u63d0\u4f9b\u7684\u7f8e\u672f\u8d44\u6e90,\u97f3\u4e50\u548c\u97f3\u6548,\u4f46\u662f\u4f60\u5fc5\u987b\u5728\u6e38\u620f\u4e2d\u5305\u542b\u4e00\u4e0b\u4fe1\u606f:&#8221;Artwork\/sounds: from iOS Games by Tutorials book, available at http:\/\/www.raywenderlich.com&#8221;.<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u521b\u5efa\u4f60\u7684\u9879\u76ee<\/strong><\/span><\/p>\n<p>\u6253\u5f00Unity\u5e76\u9009\u62e9&#8221;File\\New Project&#8230;&#8221;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u9879\u76ee,\u5728&#8221;Create new Project&#8221;\u91cc\u70b9\u51fb&#8221;Set&#8230;&#8221;\u6807\u7b7e,\u7ed9\u65b0\u9879\u76ee\u547d\u540d\u4e3a&#8221;ZombieConga&#8221;,\u9009\u62e9\u4e00\u4e2a\u5b58\u50a8\u7684\u4f4d\u7f6e\u70b9&#8221;Save&#8221;.<\/p>\n<p>\u7136\u540e\u5728&#8221;Set up defaults for&#8221; \u9009\u62e9&#8221;2D&#8221;,\u518d\u70b9\u51fb&#8221;Create Project&#8221;:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1460\" rel=\"attachment wp-att-1460\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1460\" alt=\"new_2d_unity_project\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/new_2d_unity_project-300x204.png\" width=\"300\" height=\"204\" srcset=\"\/wp-content\/uploads\/2014\/02\/new_2d_unity_project-300x204.png 300w, \/wp-content\/uploads\/2014\/02\/new_2d_unity_project.png 625w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4e0a\u9762\u8fd9\u4e2a\u5bf9\u8bdd\u6846\u662fUnity\u4e2d\u9047\u5230\u7684\u7b2c\u4e00\u4e2a\u542b\u67092D\u7279\u6027\u7684\u8bbe\u7f6e.\u4f60\u53ef\u4ee5\u968f\u65f6\u6539\u53d8\u8fd9\u4e2a2D\u8bbe\u7f6e,\u5982\u679c\u4f60\u60f3\u66f4\u6539\u8fd9\u4e2a\u8bbe\u7f6e,\u53ef\u4ee5\u9009\u62e9&#8221;Edit\\Project Settings\\Editor&#8221;\u6253\u5f00\u7f16\u8f91\u5668\u8bbe\u7f6e,\u5728&#8221;Default Behavior Mode&#8221;\u4e2d\u6539\u6a21\u5f0f\u4e3a2D,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1444\" rel=\"attachment wp-att-1444\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1444\" alt=\"editor_settings_default_behavior\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/editor_settings_default_behavior-241x300.png\" width=\"241\" height=\"300\" srcset=\"\/wp-content\/uploads\/2014\/02\/editor_settings_default_behavior-241x300.png 241w, \/wp-content\/uploads\/2014\/02\/editor_settings_default_behavior.png 274w\" sizes=\"auto, (max-width: 241px) 100vw, 241px\" \/><\/a><\/p>\n<p>&#8220;Default Behavior Mode&#8221;(\u9ed8\u8ba4\u884c\u4e3a\u6a21\u5f0f)\u5b9a\u4e49\u4f60\u9879\u76ee\u5728\u5bfc\u5165Assets\u65f6\u7684\u9ed8\u8ba4\u5bfc\u5165\u8bbe\u7f6e,\u5f53\u8bbe\u7f6e\u4e3a3D\u6a21\u5f0f\u65f6,Unity\u5047\u8bbe\u4f60\u5c06\u5bfc\u5165\u7684\u6587\u4ef6\u521b\u5efa\u4e3a\u7eb9\u7406\u7c7b\u578b(\u5982:PNG\u6587\u4ef6);\u5f53\u8bbe\u7f6e\u4e3a2D\u65f6,Unity\u5047\u5b9a\u4f60\u60f3\u8981\u7684\u5bfc\u5165\u7684\u8d44\u6e90\u4e3aSprite\u7c7b\u578b,\u4f60\u5c06\u5728\u6559\u7a0b\u91cc\u5b66\u5230\u5173\u4e8eSprite\u8d44\u6e90\u5bfc\u5165\u8bbe\u7f6e\u5177\u4f53\u7684\u89e3\u91ca.<\/p>\n<p><strong>\u573a\u666f\u89c6\u56fe\u76842D\u6a21\u5f0f<\/strong><\/p>\n<p>\u4e0b\u4e00\u4e2a2D\u7279\u5f81\u5c31\u662f\u5728\u573a\u666f\u89c6\u56fe\u91cc\u6709\u4e2a\u63a7\u5236\u4e8c\u7ef4\u5207\u6362\u7684\u6309\u94ae,\u70b9\u51fb2D\u6309\u94ae\u53ef\u4ee5\u6fc0\u6d3b2D\u6a21\u5f0f,\u50cf\u4e0b\u9762\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1423\" rel=\"attachment wp-att-1423\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1423\" alt=\"2d_mode_in_scene_ctrl_bar\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/2d_mode_in_scene_ctrl_bar-300x35.png\" width=\"300\" height=\"35\" srcset=\"\/wp-content\/uploads\/2014\/02\/2d_mode_in_scene_ctrl_bar-300x35.png 300w, \/wp-content\/uploads\/2014\/02\/2d_mode_in_scene_ctrl_bar.png 668w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u8fd9\u4e2a\u6309\u94ae\u4f1a\u5c06\u573a\u666f\u76f8\u673a\u5728\u900f\u89c6\u89c6\u56fe\u548c\u6b63\u4ea4\u6295\u5f71\u89c6\u56fe\u4e4b\u95f4\u8fdb\u884c\u5207\u6362.\u5b83\u4eec\u6709\u4ec0\u4e48\u5dee\u522b\u5462?\u5f53\u89c2\u5bdf\u900f\u89c6\u89c6\u56fe\u65f6,\u8fdc\u79bb\u76f8\u673a\u7684\u7269\u4f53\u770b\u8d77\u6765\u66f4\u5c0f,\u5c31\u50cf\u5728\u73b0\u5b9e\u4e16\u754c\u4e2d\u773c\u775b\u770b\u7269\u4f53\u4e00\u6837,\u7136\u800c\u5f53\u6b63\u4ea4\u6295\u5f71\u89c6\u56fe\u7684\u65f6\u5019,\u7269\u4f53\u7684\u5927\u5c0f\u5e76\u4e0d\u53d7\u4e0e\u76f8\u673a\u7684\u8ddd\u79bb\u5f71\u54cd.\u56e0\u6b64,\u5728\u4e8c\u7ef4\u6a21\u5f0f\u65f6,\u4e00\u4e2a\u5bf9\u8c61\u4e0d\u7ba1\u4f4d\u7f6e\u79bb\u76f8\u673a\u8fdc\u8fd1,\u53ea\u8981\u5c3a\u5bf8\u4e0d\u53d8,\u5b83\u770b\u8d77\u6765\u5c06\u6ca1\u6709\u53d8\u5316\u7684.<\/p>\n<p>\u4e0b\u9762\u7684\u914d\u56fe\u53ef\u4ee5\u6e05\u6670\u7684\u770b\u52302D\u548c3D\u6a21\u5f0f\u89c6\u7a97\u7684\u533a\u522b.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1468\" rel=\"attachment wp-att-1468\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1468\" alt=\"scene_projection_comparison\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/scene_projection_comparison-228x300.png\" width=\"228\" height=\"300\" srcset=\"\/wp-content\/uploads\/2014\/02\/scene_projection_comparison-228x300.png 228w, \/wp-content\/uploads\/2014\/02\/scene_projection_comparison.png 366w\" sizes=\"auto, (max-width: 228px) 100vw, 228px\" \/><\/a><\/p>\n<p>\u4e0a\u4e00\u4e2a\u56fe\u7247\u4e5f\u80fd\u770b\u5230\u5f532D\u6a21\u5f0f\u542f\u7528\u65f6,\u573a\u666f\u89c6\u56fe\u7684Gizmo\u63a7\u5236\u4e5f\u662f\u9690\u85cf\u7684,\u4f60\u53ea\u80fd\u505a\u89c6\u56fe\u7684\u5e73\u79fb\u64cd\u4f5c,Y\u8f74\u6307\u5411\u4e0a,X\u8f74\u6307\u5411\u53f3.<\/p>\n<p>\u91cd\u8981:\u8fd9\u4e2a\u8bbe\u7f6e\u662f\u4e0d\u4f1a\u5f71\u54cd\u5230\u6e38\u620f\u64ad\u653e\u65f6\u6548\u679c\u7684,\u56e0\u4e3a\u5b83\u53ea\u662f\u5e2e\u52a9\u4f60\u7ec4\u7ec7\u573a\u666f\u91cc\u7684\u5bf9\u8c61,\u751a\u81f3\u540e\u671f\u4f60\u4f1a\u5728\u521b\u5efa2D\u6e38\u620f\u7684\u540c\u65f6\u521b\u90203D\u6e38\u620f,\u4f60\u53ef\u80fd\u9700\u8981\u5728\u8fd9\u4e24\u79cd\u6a21\u5f0f\u95f4\u6839\u636e\u9700\u8981\u5207\u6362,\u672c\u6559\u7a0b\u6240\u6709\u622a\u56fe\u90fd\u662f\u5728\u573a\u666f\u89c6\u56fe\u76842D\u6a21\u5f0f\u4e0b.<\/p>\n<p>\u4e3a\u4e86\u66f4\u597d\u7684\u8ddf\u7740\u6559\u7a0b\u5b66\u4e60,\u4f60\u53ef\u4ee5\u8c03\u6574Unity\u7684\u5e03\u5c40\u548c\u6559\u7a0b\u622a\u56fe\u7684\u7684\u754c\u9762\u5e03\u5c40\u4e00\u81f4,\u6559\u7a0b\u91ccUnity\u662f\u7528&#8221;Dark&#8221;\u76ae\u80a4\u8fd0\u884c\u4e8eOS X\u7cfb\u7edf\u4e0b,Dark\u76ae\u80a4\u53ea\u5728Unity Pro\u7248\u672c\u624d\u80fd\u542f\u7528.\u6211\u521b\u5efa\u4e868\u4e2a\u6253\u5f00\u7684tab,\u8c03\u6574\u4ed6\u4eec\u5982\u4e0b\u9762\u7684\u6837\u5b50,<\/p>\n<p>\u5982\u56fe\u4f60\u53ef\u4ee5\u770b\u5230,\u5de6\u4e0a\u89d2\u7531Scene,Console\u548cAnimator\u89c6\u56fe\u7ec4\u6210,\u800cGame,Project\u548cAnimation\u89c6\u56fe\u5728\u5de6\u4e0b\u89d2\u7ec4\u5408\u4e3a\u4e00\u4e2a\u9009\u9879\u5361,\u53f3\u8fb9\u4e24\u5217\u662fHierarchy\u548cInspector\u89c6\u56fe.<br \/>\n\u5f53\u7136\u6709\u65f6\u5019\u6211\u4e5f\u4f1a\u6539\u53d8\u8fd9\u79cd\u8bbe\u7f6e,\u89c6\u56fe\u7684\u5e03\u5c40\u6ca1\u6709\u4e00\u4e2a\u56fa\u5b9a\u7684\u8981\u6c42,\u53ef\u4ee5\u7531\u81ea\u5df1\u5fc3\u60c5\u968f\u610f\u5b89\u6392\u81ea\u5df1\u7684\u5de5\u4f5c\u5e03\u5c40.<\/p>\n<p><strong>\u8f7b\u677e\u5236\u9020\u7cbe\u7075(Sprites)<\/strong><\/p>\n<p><strong><\/strong><br \/>\n\u7528Unity\u65b0\u529f\u80fd\u6765\u521b\u5efa\u4e00\u4e2a\u7cbe\u7075\u6709\u591a\u5bb9\u6613?\u8bd5\u8bd5\u4e0b\u9762\u7684\u65b9\u6cd5.<br \/>\n\u7b2c\u4e00\u6b65:\u62fd\u4eceFinder\u7a97\u53e3\u62fdcat.png\u6587\u4ef6\u5230Scene\u89c6\u56fe,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1470\" rel=\"attachment wp-att-1470\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1470\" alt=\"simple_sprite_add\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/simple_sprite_add-300x156.gif\" width=\"300\" height=\"156\" \/><\/a><\/p>\n<p>\u7b2c\u4e8c\u6b65:\u7a7a\u95f2\u65f6\u5199\u7ed9Unity\u7684\u5f00\u53d1\u8005\u5199\u5c01\u611f\u8c22\u4fe1,\u54c8\u54c8.<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u521b\u5efa\u6210\u529f\u7cbe\u7075,\u4ece\u7b2c\u4e00\u6b65\u5f00\u59cb\u91cd\u8bd5\u4e00\u6b21.<\/p>\n<p>\u6ce8:\u60f3\u77e5\u9053\u4e3a\u4ec0\u4e48\u4e0a\u9762\u52a8\u753b\u6709\u4e24\u4e2a\u732b\u7684\u56fe\u7247?\u522b\u62c5\u5fc3,\u6211\u540e\u9762\u4f1a\u544a\u8bc9\u4f60.<\/p>\n<p>\u5982\u6b64\u7b80\u5316\u7684\u5bfc\u5165\u4f9d\u9760Unity\u9ed8\u8ba4\u5bfc\u5165\u8bbe\u7f6e,\u867d\u7136\u8fd9\u5e38\u5e38\u4e0d\u662f\u6700\u7ec8\u9700\u8981\u7684\u6b63\u786e\u6548\u679c,\u4f46\u8db3\u4ee5\u8bf4\u660eUnity\u7684\u65b0\u529f\u80fd\u5c06\u4f7f2D\u6e38\u620f\u5f00\u53d1\u5f02\u5e38\u7b80\u5355!\u672c\u6559\u7a0b\u540e\u9762\u6db5\u76d6\u4e86\u6240\u6709\u4f60\u4f7f\u7528Unity 2D\u5f00\u53d1\u6e38\u620f\u9700\u8981\u4e86\u89e3\u7684\u77e5\u8bc6.<\/p>\n<p><strong>Sprite \u8d44\u6e90<\/strong><\/p>\n<p>\u5728Hierarchy\u89c6\u56fe\u91cc\u9009\u62e9cat,\u7136\u540e\u770bInspector.\u4f60\u7684Inspector\u89c6\u56fe\u4f4d\u7f6e\u53ef\u80fd\u548c\u4e0b\u56fe\u4e0d\u592a\u4e00\u6837,\u4f46\u4e0d\u5fc5\u62c5\u5fc3\u8fd9\u4e0d\u91cd\u8981,\u8fd9\u91cc\u8981\u6ce8\u610f\u7684\u662f\u4e3a\u4e86\u8ba9cat\u5728\u573a\u666f\u4e2d\u663e\u793a,Unity\u9644\u52a0\u4e86\u4e00\u4e2aSprite Renderer\u7ec4\u4ef6\u5230GameObject.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1438\" rel=\"attachment wp-att-1438\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1438\" alt=\"cat_in_inspector-264x500\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/cat_in_inspector-264x500-158x300.png\" width=\"158\" height=\"300\" srcset=\"\/wp-content\/uploads\/2014\/02\/cat_in_inspector-264x500-158x300.png 158w, \/wp-content\/uploads\/2014\/02\/cat_in_inspector-264x500.png 264w\" sizes=\"auto, (max-width: 158px) 100vw, 158px\" \/><\/a><\/p>\n<p>Unity\u4f1a\u4e3a\u8fd9\u4e2a\u7269\u4f53\u521b\u5efa\u7f51\u683c,Unity\u4f1a\u57fa\u4e8e\u56fe\u50cf\u7684\u975e\u900f\u660e\u90e8\u5206\u521b\u5efa\u7f51\u683c,\u4e0b\u56fe\u91cc\u7684\u50f5\u5c38\u7684\u84dd\u8272\u7f51\u683c\u5c31\u662f:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1479\" rel=\"attachment wp-att-1479\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1479\" alt=\"sprite_mesh\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_mesh.png\" width=\"210\" height=\"210\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_mesh.png 210w, \/wp-content\/uploads\/2014\/02\/sprite_mesh-150x150.png 150w\" sizes=\"auto, (max-width: 210px) 100vw, 210px\" \/><\/a><\/p>\n<p>\u901a\u8fc7\u8fd9\u6837\u521b\u5efa\u7684\u7eb9\u7406\u7f51\u683c,\u53ef\u4ee5\u6709\u52a9\u4e8eUnity\u63d0\u9ad8\u573a\u666f\u8fd0\u884c\u65f6\u7684fill rate,\u4e5f\u4f7f\u5f97\u521b\u5efa\u591a\u8fb9\u5f62\u78b0\u649e\u76d2\u66f4\u5bb9\u6613,\u6559\u7a0b\u540e\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u521b\u5efa\u4f7f\u7528\u78b0\u649e\u76d2.<\/p>\n<p>\u6ce8\u610f:\u522b\u8ba9\u50f5\u5c38\u7a81\u7136\u51fa\u73b0\u60ca\u5413\u5230\u4f60,\u6211\u53ea\u662f\u89c9\u5f97\u5b83\u6bd4\u53ef\u7231\u7684\u5c0f\u732b\u66f4\u6709\u8da3.<\/p>\n<p>\u5728\u672c\u8282\u6559\u7a0b\u4e2d\u4f60\u5c06\u4e86\u89e3Sprite\u7684\u6e32\u67d3\u5668\u7ec4\u4ef6\u5c5e\u6027,\u53ef\u4ee5\u770b\u5230Sprite\u7684\u540d\u79f0.\u4e0b\u56fe\u91cc\u4f60\u53ef\u4ee5\u770b\u5230&#8221;cat&#8221;\u5bf9\u8c61\u5728\u7cbe\u7075\u6e32\u67d3\u5668\u91cc\u88ab\u5206\u914d\u7684\u540d\u5b57\u662f&#8221;cat&#8221;.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1478\" rel=\"attachment wp-att-1478\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1478\" alt=\"sprite_field_in_inspector\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_field_in_inspector.png\" width=\"280\" height=\"296\" \/><\/a><\/p>\n<p>\u786e\u4fddProject\u89c6\u56fe\u662f\u53ef\u89c1\u7684,\u5728Inspector\u89c6\u56fe\u91cc\u60e6\u8bb0Sprite\u7f16\u8f91\u6846\u80fd\u770b\u5230Sprite\u8d44\u6e90\u5c06\u5728Project\u89c6\u56fe\u91cc\u5448\u73b0\u9ad8\u4eae\u72b6\u6001,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1456\" rel=\"attachment wp-att-1456\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1456\" alt=\"highlighted_cat\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/highlighted_cat-300x118.png\" width=\"300\" height=\"118\" srcset=\"\/wp-content\/uploads\/2014\/02\/highlighted_cat-300x118.png 300w, \/wp-content\/uploads\/2014\/02\/highlighted_cat.png 455w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Project\u89c6\u56fe\u4e2dcat\u7cbe\u7075\u9ad8\u4eae<\/p>\n<p>\u6ce8:\u9ad8\u4eae\u8fb9\u6846\u4f1a\u5728\u51e0\u79d2\u540e\u6d88\u5931,\u6240\u4ee5\u5982\u679c\u4f60\u4e0d\u5c0f\u5fc3\u9519\u8fc7\u5b83,\u53ef\u4ee5\u518d\u6b21\u70b9\u51fb\u4e00\u6b21Sprite\u7f16\u8f91\u6846.\u5f53\u7136\u73b0\u5728\u9879\u76ee\u91cc\u53ea\u6709\u4e00\u4e2a\u8d44\u6e90,\u4f60\u4e0d\u53ef\u80fd\u9519\u8fc7\u5b83.:]<\/p>\n<p>\u6b63\u5982\u4e0a\u4e00\u4e2a\u622a\u56fe\u4f60\u6240\u770b\u5230\u7684,Unity\u4f1a\u5728Project\u89c6\u56fe\u91cc\u9ad8\u4eae\u663e\u793acat\u9879,\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u4e5f\u53ebcat\u7684\u5b50\u9879.\u4e24\u53ea\u732b\u90fd\u5728Project\u89c6\u56fe\u91cc,\u5f88\u5bb9\u6613\u6df7\u6dc6\u554a,\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462:<\/p>\n<p>\u7236\u7ea7\u7684cat\u662f\u7eb9\u7406\u8d44\u6e90.\u5b83\u5c06\u5173\u8054\u5230\u4f60\u5bfc\u5165\u7684\u539f\u59cb\u7f8e\u672f\u8d44\u6e90\u6587\u4ef6cat.png,\u4ee5\u53ca\u63a7\u5236\u7740\u5982\u4f55\u4ece\u8fd9\u4e2a\u7eb9\u7406\u8d44\u6e90\u521b\u5efaSprites,\u4f60\u53ef\u4ee5\u770b\u5230\u5b83\u6709\u4e2a\u6587\u4ef6\u5185\u5bb9\u7684\u7f29\u7565\u56fe.<\/p>\n<p>\u5b50\u96c6\u7684cat\u662fUnity\u5bfc\u5165cat.png\u65f6\u521b\u5efa\u7684Sprite\u8d44\u6e90.\u73b0\u5728\u53ea\u6709\u4e00\u4e2a\u5b50\u9879,\u56e0\u4e3aUnity\u53ea\u4ece\u6587\u4ef6\u91cc\u521b\u5efa\u4e86\u4e00\u4e2aSprite,\u6559\u7a0b\u540e\u9762\u5c06\u6559\u4f60\u521b\u5efa&#8221;slicing sprite&#8221;,\u5373\u4ece\u4e00\u4e2a\u56fe\u7247\u521b\u5efa\u51fa\u591a\u4e2aSprites.<\/p>\n<p>\u6ce8:Unity\u6e32\u67d3Sprite\u5bf9\u8c61\u5b9e\u9645\u4e0a\u662f\u7531\u4e00\u4e2aTexture2D\u751f\u6210\u7684,\u56fe\u50cf\u4fe1\u606f\u5b9e\u9645\u662f\u5b58\u50a8\u4e8e\u56fe\u7247\u6587\u4ef6\u4e2d,\u4f60\u4e5f\u53ef\u4ee5\u52a8\u6001\u7684\u521b\u5efa\u81ea\u5df1\u9700\u8981\u7684Texture2D\u5bf9\u8c61\u6765\u8fd0\u884c\u65f6\u751f\u6210Sprite,\u8fd9\u4e2a\u8fdb\u9636\u7684\u77e5\u8bc6\u672c\u6559\u7a0b\u5c31\u5148\u4e0d\u8bb2\u4e86.<\/p>\n<p>\u6bd4\u5982cat.png,\u4f60\u53ef\u4ee5\u4eceFinder\u4e2d\u62fd\u4e00\u4e2a\u56fe\u7247\u5230Scene\u89c6\u56fe(\u6216\u8005Hierarchy\u89c6\u56fe,\u968f\u4f60\u81ea\u5df1)\u4e2d\u521b\u5efaSprites.\u4f46\u662f\u66f4\u5e38\u89c1\u7684\u662f\u5148\u6dfb\u52a0\u8d44\u6e90\u5230Project\u91cc\u5728\u6dfb\u52a0\u5b83\u5230\u573a\u666f\u4e2d.<\/p>\n<p>\u5c06\u4e0b\u8f7d\u5230\u7684\u6587\u4ef6\u6dfb\u52a0\u5230\u9879\u76ee\u91cc:background.png, enemy.png, \u548c zombie.png.Unity\u63d0\u4f9b\u4e86\u4e94\u79cd\u65b9\u6cd5\u8ba9\u4f60\u5c06\u8d44\u6e90\u5bfc\u5165\u9879\u76ee\u4e2d:<br \/>\n\u4eceFinder\u7a97\u53e3\u62d6\u62fd\u6587\u4ef6\u5230Project\u89c6\u56fe.<br \/>\n\u5230&#8221;Assets\\Import New Asset\u2026&#8221;\u83dc\u5355,\u9009\u62e9\u6587\u4ef6\u5e76\u70b9\u51fbImport.<br \/>\n\u5728Project\u89c6\u56fe\u4e2d\u53f3\u952e\u9009\u62e9&#8221;Assets\\Import New Asset\u2026&#8221;\u83dc\u5355,\u9009\u62e9\u6587\u4ef6\u5e76\u70b9\u51fbImport.<br \/>\n\u5728\u4f60\u7684\u7cfb\u7edf\u4e2d\u76f4\u63a5\u6dfb\u52a0\u6587\u4ef6\u6216\u8005\u521b\u5efa\u5b50\u76ee\u5f55\u5230\u9879\u76ee\u7684Assets\u76ee\u5f55,Unity\u4f1a\u81ea\u52a8\u5237\u65b0\u663e\u793a\u6700\u65b0\u7684\u8d44\u6e90\u5185\u5bb9.\u4e0d\u8fc7\u8981\u6ce8\u610f,\u4e00\u5b9a\u4e0d\u8981\u76f4\u63a5\u4ece\u6587\u4ef6\u7cfb\u7edf\u91cc\u5220\u9664\u4e0d\u7528\u7684\u8d44\u6e90,\u8981\u603b\u662f\u4eceUnity\u7f16\u8f91\u5668\u5185\u90e8\u5220\u9664\u8d44\u6e90,\u56e0\u4e3aUnity\u4f1a\u5b58\u50a8\u6709\u5173\u9879\u76ee\u7684\u8d44\u6e90metadate,\u76f4\u63a5\u4ece\u6587\u4ef6\u7cfb\u7edf\u4fee\u6539\u5220\u9664\u53ef\u80fd\u635f\u574f\u9879\u76ee\u7ed3\u6784.<\/p>\n<p>\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5c06\u6587\u4ef6Hierarchy\u6216\u8005Scene\u89c6\u56fe,\u4e0d\u8fc7\u8fd9\u6837\u505a\u662f\u76f4\u63a5\u5728\u5f53\u524d\u573a\u666f\u4e2d\u521b\u5efa\u4e00\u4e2aGameObject.<\/p>\n<p>\u4eceProject\u89c6\u56fe\u91cc\u62d6\u62fdenemy\u5230Hierachy\u89c6\u56fe.\u548ccat\u4e00\u6837,\u540c\u6837\u4f1a\u6709\u4e24\u4e2a\u540d\u5b57\u4e3aenemy\u9879\u51fa\u73b0\u5728Project\u89c6\u56fe\u4e2d,\u5f53\u73b0\u5728\u8fd9\u6837\u53ea\u6709\u4e00\u4e2a\u5b50\u7cbe\u7075\u7684\u65f6\u5019,\u4f60\u9009\u62e9\u62d6\u62fd\u54ea\u4e2aenemy\u5230Hierarchy\u89c6\u56fe\u90fd\u662f\u4e00\u6837\u7684.<br \/>\n\u5728Hierarchy\u89c6\u56fe\u91cc\u9009\u62e9enemy,\u8bbe\u7f6eTransform\u7ec4\u4ef6\u7684\u4f4d\u7f6e\u4e3a(2,0,0),\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1447\" rel=\"attachment wp-att-1447\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1447\" alt=\"enemy_initial_position\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/enemy_initial_position.png\" width=\"276\" height=\"135\" \/><\/a><\/p>\n<p>enemy\u7684\u521d\u59cb\u4f4d\u7f6e.<\/p>\n<p>\u73b0\u5728\u573a\u666f\u89c6\u56fe\u91cc\u663e\u5f97\u6709\u70b9\u4e71,\u5728Hierachy\u89c6\u56fe\u91cc\u9009\u62e9cat\u5e76\u8bbe\u7f6e\u5b83\u7684\u4f4d\u7f6e\u4e3a(0,2,0),\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1439\" rel=\"attachment wp-att-1439\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1439\" alt=\"cat_initial_position\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/cat_initial_position.png\" width=\"275\" height=\"133\" \/><\/a><\/p>\n<p>\u4f60\u7684\u573a\u666f\u73b0\u5728\u4f1a\u50cf\u4e0b\u56fe\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1437\" rel=\"attachment wp-att-1437\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1437\" alt=\"cat_and_enemy_scene\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/cat_and_enemy_scene-300x149.png\" width=\"300\" height=\"149\" srcset=\"\/wp-content\/uploads\/2014\/02\/cat_and_enemy_scene-300x149.png 300w, \/wp-content\/uploads\/2014\/02\/cat_and_enemy_scene.png 454w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\ncat\u548cenemy\u5728Scene\u89c6\u56fe<\/p>\n<p>\u6700\u540e,\u4eceProject\u89c6\u56fe\u62d6\u62fdbackground\u5230Hierachy\u89c6\u56fe\u91cc,\u5e76\u8bbe\u7f6e\u4f4d\u7f6e\u4e3a(0,0,0),\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1430\" rel=\"attachment wp-att-1430\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1430\" alt=\"background_initial_position\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/background_initial_position.png\" width=\"272\" height=\"132\" \/><\/a><\/p>\n<p>\u4f60\u53ef\u4ee5\u7a0d\u665a\u4e9b\u8c03\u6574\u80cc\u666f\u56fe\u50cf\u7684\u8d28\u91cf,\u6240\u4ee5\u73b0\u5728\u4e0d\u7528\u62c5\u5fc3\u5b83\u73b0\u5728\u4e0d\u6b63\u786e\u7684\u6837\u5b50.(\u63d0\u793a:Unity\u9ed8\u8ba4\u8bbe\u7f6e\u5728\u5bfc\u5165background.png\u65f6\u662f\u4e0d\u6b63\u786e\u7684(,Scene\u89c6\u56fe\u73b0\u5728\u4f1a\u662f\u8fd9\u6837\u5b50:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1469\" rel=\"attachment wp-att-1469\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1469\" alt=\"scene_with_just_bg\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/scene_with_just_bg-300x146.png\" width=\"300\" height=\"146\" srcset=\"\/wp-content\/uploads\/2014\/02\/scene_with_just_bg-300x146.png 300w, \/wp-content\/uploads\/2014\/02\/scene_with_just_bg.png 554w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u53ea\u663e\u793a\u80cc\u666f\u7684\u573a\u666f\u89c6\u56fe<\/p>\n<p>\u73b0\u5728\u770b\u4e0d\u5230cat\u548c\u6b27\u5df4\u6851\u6ca1\u5173\u7cfb,\u5b83\u4eec\u53ea\u662f\u88ab\u80cc\u666f\u6682\u65f6\u6321\u4f4f\u4e86.\u53ef\u4ee5\u5f88\u5bb9\u6613\u7684\u8c03\u6574\u51fa\u6765,\u5728\u8c03\u6574\u4ed6\u4eec\u5c42\u6b21\u4e4b\u524d,\u6211\u4eec\u9700\u8981\u5207\u4e00\u5177\u5c38\u4f53,\u563f\u563f,\u4e00\u5177corpse Sprites,\u50cf\u8fd9\u6837:<\/p>\n<p><strong>\u5207\u7247\u7cbe\u7075\u8868(Slicing Sprite Sheets)<\/strong><\/p>\n<p>\u5df2\u7ecf\u5bfc\u5165zombie.png\u5230\u9879\u76ee\u4e86,\u4f60\u4f1a\u53d1\u73b0\u8fd9\u4e2a\u6587\u4ef6\u548c\u5176\u5b83\u6587\u4ef6\u4e0d\u540c,\u5b83\u5305\u542b\u4e86\u597d\u591a\u4e2a\u56fe\u50cf,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1506\" rel=\"attachment wp-att-1506\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1506\" alt=\"zombie\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie-300x48.png\" width=\"300\" height=\"48\" srcset=\"\/wp-content\/uploads\/2014\/02\/zombie-300x48.png 300w, \/wp-content\/uploads\/2014\/02\/zombie.png 628w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u8fd9\u79cd\u6587\u4ef6\u901a\u5e38\u88ab\u79f0\u4e3a\u7cbe\u7075\u8868(sprite sheet),\u6211\u4eec\u5c06\u4e3a\u8868\u91cc\u7684\u6bcf\u4e2a\u56fe\u50cf\u521b\u5efa\u5355\u72ec\u7684Sprite.\u5728Project\u89c6\u56fe\u91cc\u5c55\u5f00zombie,\u80fd\u770b\u5230\u50cf\u4e0b\u9762\u622a\u56fe\u8fd9\u6837,Unity\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u6240\u6709\u56fe\u50cf\u7684Sprite.\u8fd9\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1496\" rel=\"attachment wp-att-1496\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1496\" alt=\"zombie_as_single_sprite\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_as_single_sprite-300x171.png\" width=\"300\" height=\"171\" srcset=\"\/wp-content\/uploads\/2014\/02\/zombie_as_single_sprite-300x171.png 300w, \/wp-content\/uploads\/2014\/02\/zombie_as_single_sprite.png 550w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Unity\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u7684\u89e3\u51b3\u65b9\u6848,\u53ef\u4ee5\u6765\u5904\u7406\u8fd9\u4e2a\u9700\u6c42,\u5728Porject\u89c6\u56fe\u9009\u62e9zombie\u7684\u9876\u5c42\u7ea7\u540e\u4f1a\u770b\u5230Inspector\u4e2d\u663e\u793a\u4e86\u5b83\u7684Import Settings,\u8bbe\u7f6eSprite\u6a21\u5f0f\u5230Multiple\u5e76\u70b9\u51fbApply:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1502\" rel=\"attachment wp-att-1502\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1502\" alt=\"zombie_import_settings\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_import_settings.png\" width=\"275\" height=\"288\" \/><\/a><\/p>\n<p>\u9009\u62e9\u8fd9\u4e2a\u9009\u9879\u540e\u5728Sprite\u7f16\u8f91\u5668\u4e2d\u4f1a\u51fa\u73b0\u4e00\u4e2a\u65b0\u7684\u6309\u94ae,\u5e76\u4e14\u8fd8\u79fb\u9664\u4e86Pivot\u5c5e\u6027,\u56e0\u4e3a\u6bcf\u4e2aSprite\u90fd\u5c06\u5b9a\u4e49\u81ea\u5df1\u7684\u8f74\u70b9.<\/p>\n<p>\u4e0d\u77e5\u9053\u4ec0\u4e48\u662f\u66f2\u8f74\u70b9(Pivot points)?Sprite Pivot\u5b9a\u4e49\u4e86\u7cbe\u7075\u5728\u5c40\u90e8\u5750\u6807\u7cfb\u4e2d\u7684\u539f\u70b9,\u4f8b\u5982,Sprite\u7684\u67a2\u8f74\u70b9\u5728\u7cbe\u7075\u7684\u4e2d\u5fc3\u6216\u8005\u5de6\u4e0a\u65b9,\u7f29\u653e\u5b83\u6216\u8005\u65cb\u8f6c\u5b83\u65f6,\u7cbe\u7075\u5c06\u56f4\u7ed5\u8fd9\u4e2a\u539f\u70b9\u8fdb\u884c\u53d8\u6362.<\/p>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7Pivot\u7ec4\u5408\u6846\u6765\u6307\u5b9a\u7cbe\u7075\u7684\u67a2\u8f74\u70b9,\u6211\u4eec\u6765\u770b\u81ea\u5b9a\u4e49\u67a2\u8f74\u7f16\u8f91\u5668(Custom pivot editor).<\/p>\n<p>\u8f74\u7684X\u548cY\u7684\u503c\u662f0~1,\u6240\u4ee50.5\u7684\u65f6\u5019\u662f\u4e2d\u592e,\u4f46\u662f\u4f60\u53ef\u4ee5\u7528\u5c0f\u4e8e0\u7684\u503c\u6216\u5927\u4e8e1\u7684\u503c\u6765\u8bbe\u5b9a\u67a2\u8f74\u5728\u7cbe\u7075\u8303\u56f4\u5916.<\/p>\n<p>\u5728Project\u89c6\u56fe(\u5982\u4e0b\u56fe)\u91cc,zombie\u7eb9\u7406\u8d44\u6e90\u56fe\u6807\u53f3\u4fa7\u6ca1\u6709\u5c0f\u7bad\u5934,\u4e5f\u5c31\u662f\u8bf4\u5b83\u4e0d\u5305\u542b\u4efb\u4f55\u5b50\u7269\u4f53.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1497\" rel=\"attachment wp-att-1497\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1497\" alt=\"zombie_before_slice\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_before_slice-300x171.png\" width=\"300\" height=\"171\" srcset=\"\/wp-content\/uploads\/2014\/02\/zombie_before_slice-300x171.png 300w, \/wp-content\/uploads\/2014\/02\/zombie_before_slice.png 550w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u5728\u8fd9\u79cd\u72b6\u6001\u4e0bzombie\u7eb9\u7406\u662f\u4e0d\u53ef\u7528\u7684,\u5982\u679c\u4f60\u5c1d\u8bd5\u5c06\u5b83\u62d6\u5230Hierarchy\u7684\u65f6\u5019,Unity\u4f1a\u63d0\u793a\u5b83\u4e0d\u5305\u542b\u7cbe\u7075.\u8fd9\u662f\u56e0\u4e3a\u6211\u4eec\u8fd8\u9700\u8981\u544a\u8bc9Unity\u600e\u4e48\u5207\u5206\u4f7f\u7528\u8fd9\u4e2a\u7cbe\u7075\u8868.\u5728Project\u89c6\u56fe\u4e2d\u9009\u62e9zombie,\u5e76\u5728Inspector\u4e2d\u70b9\u51fb\u7cbe\u7075\u7f16\u8f91\u5668(Sprite Editor)\u6253\u5f00\u5982\u4e0b\u7a97\u53e3:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1476\" rel=\"attachment wp-att-1476\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1476\" alt=\"sprite_editor\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_editor-300x200.png\" width=\"300\" height=\"200\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_editor-300x200.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_editor.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u7cbe\u7075\u7f16\u8f91\u5668\u5141\u8bb8\u5b9a\u4e49\u5305\u542b\u7684\u56fe\u50cf\u600e\u4e48\u6837\u6765\u505a\u4e3a\u4e00\u4e2a\u7cbe\u7075.\u5355\u51fb\u7a97\u53e3\u5de6\u4e0a\u65b9\u6765\u5f00\u59cb\u5b9a\u4e49\u7cbe\u7075,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1471\" rel=\"attachment wp-att-1471\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1471\" alt=\"slice_button\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/slice_button.png\" width=\"270\" height=\"56\" \/><\/a><br \/>\n\u7cbe\u7075\u7f16\u8f91\u5668\u7684slice\u6309\u94ae<\/p>\n<p>Unity\u80fd\u6839\u636e\u56fe\u7247\u81ea\u52a8\u627e\u5230\u7cbe\u7075,\u540c\u6837\u4f60\u4e5f\u53ef\u4ee5\u8c03\u6574\u5b83\u81ea\u52a8\u5904\u7406\u7684\u7ed3\u679c.\u8fd9\u91cc\u6211\u4eec\u7528\u5b83\u9ed8\u8ba4\u8bbe\u7f6e,\u70b9\u51fbSlice\u6309\u94ae.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1441\" rel=\"attachment wp-att-1441\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1441\" alt=\"default_slice_options\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/default_slice_options-300x177.png\" width=\"300\" height=\"177\" srcset=\"\/wp-content\/uploads\/2014\/02\/default_slice_options-300x177.png 300w, \/wp-content\/uploads\/2014\/02\/default_slice_options.png 304w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u9ed8\u8ba4\u5207\u7247\u9009\u9879<\/p>\n<p>Unity\u662f\u57fa\u4e8e\u8d34\u56fe\u7684\u900f\u660e\u5ea6\u6765\u786e\u5b9a\u7cbe\u7075\u5207\u5206\u8303\u56f4\u7684.\u4f60\u53ef\u4ee5\u770b\u5230\u5b83\u627e\u5230\u7684\u7cbe\u7075\u90fd\u4f1a\u6709\u4e00\u4e2a\u7ebf\u6846\u8868\u793a.\u73b0\u5728,\u6211\u4eec\u770b\u5230Unity\u627e\u5230\u4e864\u4e2a\u7cbe\u7075:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1428\" rel=\"attachment wp-att-1428\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1428\" alt=\"auto_sliced_sprites\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/auto_sliced_sprites-300x73.png\" width=\"300\" height=\"73\" srcset=\"\/wp-content\/uploads\/2014\/02\/auto_sliced_sprites-300x73.png 300w, \/wp-content\/uploads\/2014\/02\/auto_sliced_sprites.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u5e38\u89c4\u6765\u8bb2\u5f53\u56fe\u7247\u5e03\u7f6e\u7684\u5f88\u597d(\u5e26\u6709\u660e\u786e\u7684\u7a7a\u767d\u5206\u5272\u7a7a\u95f4)\u65f6Unity\u7684\u81ea\u52a8\u5207\u5272\u6548\u679c\u662f\u6700\u597d\u7684,\u50cf\u4e0b\u56feUnity\u53ea\u627e\u5230\u4e86\u7b11\u8138\u7cbe\u7075,\u5176\u4ed6\u7cbe\u7075\u5b83\u5e76\u6ca1\u6709\u81ea\u52a8\u8bc6\u522b\u51fa\u6765:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1448\" rel=\"attachment wp-att-1448\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1448\" alt=\"example_of_broken_auto_slice\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/example_of_broken_auto_slice-300x277.png\" width=\"300\" height=\"277\" srcset=\"\/wp-content\/uploads\/2014\/02\/example_of_broken_auto_slice-300x277.png 300w, \/wp-content\/uploads\/2014\/02\/example_of_broken_auto_slice.png 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u9519\u8fc7\u7684\u7cbe\u7075<\/p>\n<p>\u56e0\u4e3a\u4e24\u4e2aBox\u91cd\u53e0\u76f8\u4ea4\u6240\u4ee5Unity\u4e0d\u80fd\u627e\u5230\u6240\u6709\u7cbe\u7075.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1449\" rel=\"attachment wp-att-1449\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1449\" alt=\"example_of_working_auto_slice\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/example_of_working_auto_slice-300x277.png\" width=\"300\" height=\"277\" srcset=\"\/wp-content\/uploads\/2014\/02\/example_of_working_auto_slice-300x277.png 300w, \/wp-content\/uploads\/2014\/02\/example_of_working_auto_slice.png 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nUnity\u80fd\u627e\u5230\u4e09\u4e2a\u7cbe\u7075,\u56e0\u4e3a\u6bcf\u4e2a\u7cbe\u7075\u90fd\u6709\u660e\u663e\u7684\u8fb9\u754c\u95f4\u9699.<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u8981\u7ec6\u81f4\u7684\u5b89\u6392\u7cbe\u7075\u8868\u4e2d\u7684\u56fe\u50cf.\u5728\u7f16\u8f91\u5668\u4e2d\u70b9\u51fbUnity\u81ea\u52a8\u8bc6\u522b\u7684\u4efb\u610f\u4e00\u4e2a\u7cbe\u7075\u90fd\u5c06\u663e\u793a\u7cbe\u7075\u8be6\u60c5\u7a97\u53e3,\u5305\u542b\u5176\u540d\u79f0,\u4f4d\u7f6e,\u8fb9\u754c\u548c\u4e2d\u5fc3\u70b9,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1485\" rel=\"attachment wp-att-1485\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1485\" alt=\"sprite_selected_in_editor\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_selected_in_editor-300x200.png\" width=\"300\" height=\"200\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_selected_in_editor-300x200.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_selected_in_editor.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u6539\u53d8\u8fd9\u91cc\u7684\u503c,\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728\u56fe\u50cf\u4e2d\u8c03\u6574\u8303\u56f4\u548c\u4e2d\u5fc3\u70b9\u4f4d\u7f6e.<br \/>\n\u901a\u5e38,\u505a\u4e86\u66f4\u6539\u540e,\u8981\u70b9\u51fb\u5e94\u7528(Appley)\u6216\u8005\u8fd8\u539f(Revert)\u6309\u94ae\u6765\u4fdd\u5b58\u6216\u8005\u653e\u5f03\u505a\u7684\u4fee\u6539.<\/p>\n<p>\u4ed4\u7ec6\u89c2\u5bdf\u4f60\u4f1a\u53d1\u73b0,zombie.png\u7684\u56fe\u7247\u662f\u5b89\u6392\u5728\u56db\u4e2a\u540c\u6837\u5927\u5c0f\u7684\u4e3e\u884c\u4e2d,\u9488\u5bf9\u4e8e\u8fd9\u79cd\u7cbe\u7075\u8868Unity\u6709\u4e2a\u5355\u72ec\u7684\u9009\u9879\u6765\u5904\u7406\u5b83.<br \/>\n\u5728Sprite Editor\u7684\u5de6\u4e0a\u89d2\u5355\u51fbSlice\u518d\u6b21\u6253\u5f00\u5207\u7247\u8bbe\u7f6e\u7a97\u53e3,\u8fd9\u6b21\u9009\u62e9\u7c7b\u578b\u4e3aGrid,\u5207\u7247\u8bbe\u7f6e\u5c06\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1474\" rel=\"attachment wp-att-1474\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1474\" alt=\"sprite_editor_grid_defaults\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_editor_grid_defaults-300x183.png\" width=\"300\" height=\"183\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_editor_grid_defaults-300x183.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_editor_grid_defaults.png 308w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Pixel size\u5b57\u6bb5\u5141\u8bb8\u6307\u5b9a\u7f51\u683c\u5355\u5143\u683c\u7684\u5927\u5c0f.X\u5b9a\u4e49\u6bcf\u4e2a\u5355\u5143\u683c\u7684\u5bbd\u5ea6,Y\u4e3a\u9ad8\u5ea6.Unity\u4f1a\u7528\u8fd9\u4e9b\u503c\u4ece\u56fe\u50cf\u7684\u5de6\u4e0a\u89d2\u6765\u7b49\u5206\u56fe\u50cf.<\/p>\n<p>\u6211\u4eec\u5c06X\u8bbe\u5b9a\u4e3a157,Y\u8bbe\u5b9a\u4e3a102,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1475\" rel=\"attachment wp-att-1475\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1475\" alt=\"sprite_editor_grid_settings\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_editor_grid_settings-300x109.png\" width=\"300\" height=\"109\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_editor_grid_settings-300x109.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_editor_grid_settings.png 308w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u5207\u7247\u7f51\u683c\u5927\u5c0f\u8bbe\u7f6e.<\/p>\n<p>\u70b9\u51fbSlice\u6309\u94ae,Unity\u4f1a\u627e\u5230\u4e0b\u9762\u56db\u4e2a\u7cbe\u7075:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1501\" rel=\"attachment wp-att-1501\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1501\" alt=\"zombie_grid\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_grid-300x60.png\" width=\"300\" height=\"60\" srcset=\"\/wp-content\/uploads\/2014\/02\/zombie_grid-300x60.png 300w, \/wp-content\/uploads\/2014\/02\/zombie_grid.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u5728\u5207\u7247\u7f51\u683c\u4e2d\u7684zombie\u7cbe\u7075.<\/p>\n<p>\u8fd9\u65f6\u4f60\u4ecd\u7136\u53ef\u4ee5\u5355\u72ec\u9009\u62e9\u7f51\u683c\u4e2d\u7684\u7cbe\u7075\u6765\u5fae\u8c03\u5355\u4e2a\u7cbe\u7075\u7684\u8bbe\u7f6e,\u4e0d\u8fc7\u4e00\u822c\u60c5\u51b5\u4e0b\u662f\u6ca1\u5fc5\u8981\u7684.<\/p>\n<p>\u5728\u7cbe\u7075\u7f16\u8f91\u5668\u5de6\u4e0a\u89d2\u70b9\u51fb\u5e94\u7528(Apply)\u63d0\u4ea4\u66f4\u6539.Unity\u4f1a\u66f4\u65b0\u9879\u76ee\u8d44\u6e90,\u4f60\u53ef\u4ee5\u5728Project\u89c6\u56fe\u91cc\u770b\u5230zombie\u4f1a\u5305\u542b\u5b50\u7cbe\u7075,\u540d\u5b57\u5206\u522b\u662fzombie_0, zombie_1\u7b49\u7b49,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1472\" rel=\"attachment wp-att-1472\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1472\" alt=\"sliced_zombie_in_project\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sliced_zombie_in_project-300x135.png\" width=\"300\" height=\"135\" srcset=\"\/wp-content\/uploads\/2014\/02\/sliced_zombie_in_project-300x135.png 300w, \/wp-content\/uploads\/2014\/02\/sliced_zombie_in_project.png 672w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u73b0\u5728\u4f60\u638c\u63e1\u4e86\u4e24\u79cd\u8bbe\u7f6e\u7cbe\u7075\u7684\u65b9\u5f0f,\u8fd9\u4e24\u79cd\u65b9\u5f0f\u8981\u6d3b\u5b66\u6d3b\u7528,\u540c\u6837\u53ef\u4ee5\u7528\u4e8e\u80cc\u666f\u7684\u5236\u4f5c.<\/p>\n<p>\u901a\u8fc7\u9009\u62e9&#8221;GameObject\\CreateEmpty&#8221;\u83dc\u5355\u6211\u4eec\u6765\u521b\u5efa\u4e00\u4e2a\u7a7aGameObject,\u547d\u540d\u4e3azombie\u5e76\u8bbe\u7f6e\u4f4d\u7f6e\u4e3a(-2,0,0)\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1446\" rel=\"attachment wp-att-1446\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1446\" alt=\"empty_zombie_gameobject\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/empty_zombie_gameobject.png\" width=\"276\" height=\"178\" \/><\/a><br \/>\n\u7a7azombie GameObject<\/p>\n<p>\u5728Hierarchy\u89c6\u56fe\u4e2d\u9009\u62e9zombie\u5e76\u7528&#8221;Add Component&#8221;\u6dfb\u52a0\u4e00\u4e2aSprite Renderer\u7ec4\u4ef6.\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1424\" rel=\"attachment wp-att-1424\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1424\" alt=\"add_script_steps\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/add_script_steps-135x300.gif\" width=\"135\" height=\"300\" \/><\/a><\/p>\n<p>\u70b9\u51fb\u7cbe\u7075\u6e32\u67d3\u5668\u7ec4\u4ef6\u53f3\u8fb9\u7684\u5c0f\u5706\u5708\u6253\u5f00\u7cbe\u7075\u6e32\u67d3\u5668\u7684\u7cbe\u7075\u9009\u9879\u5361,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1477\" rel=\"attachment wp-att-1477\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1477\" alt=\"sprite_field_editor\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_field_editor.png\" width=\"276\" height=\"120\" \/><\/a><\/p>\n<p>\u5728\u51fa\u73b0\u7684\u5bf9\u8bdd\u6846\u4e2d\u5305\u542b\u4e24\u4e2a\u6807\u7b7e,Assets\u53caScene.\u8fd9\u91cc\u5c06\u663e\u793a\u4f60\u9879\u76ee\u6240\u6709\u7cbe\u7075\u8d44\u6e90\u548c\u573a\u666f\u4e2d\u7684\u7cbe\u7075\u8d44\u6e90.<\/p>\n<p>\u9009\u62e9Assets\u9009\u9879\u5361\u5e76\u9009\u62e9zombie_0\u5230\u7cbe\u7075\u6e32\u67d3\u5668,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1486\" rel=\"attachment wp-att-1486\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1486\" alt=\"sprite_selection_dialog\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_selection_dialog-293x300.png\" width=\"293\" height=\"300\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_selection_dialog-293x300.png 293w, \/wp-content\/uploads\/2014\/02\/sprite_selection_dialog.png 342w\" sizes=\"auto, (max-width: 293px) 100vw, 293px\" \/><\/a><\/p>\n<p>\u5728\u573a\u666f\u89c6\u56fe\u4e2d\u4f60\u80fd\u770b\u5230\u6d77\u6ee9\u4e0a\u6709\u4e2a\u60a0\u95f2\u7684\u50f5\u5c38,\u8fd8\u6709\u4e00\u4e2a\u8001\u5987\u4eba\u548c\u732b\u5728\u5b83\u4e0b\u65b9,\u7f8e\u6781\u4e86.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1503\" rel=\"attachment wp-att-1503\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1503\" alt=\"zombie_on_beach\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_on_beach-300x158.png\" width=\"300\" height=\"158\" srcset=\"\/wp-content\/uploads\/2014\/02\/zombie_on_beach-300x158.png 300w, \/wp-content\/uploads\/2014\/02\/zombie_on_beach.png 544w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u73b0\u5728\u6240\u6709\u5fc5\u8981\u7684\u7cbe\u7075\u90fd\u5728\u573a\u666f\u91cc\u4e86,\u6211\u4eec\u6765\u914d\u7f6e\u6e38\u620f\u89c6\u56fe.<\/p>\n<p><strong>\u914d\u7f6e\u6e38\u620f\u89c6\u56fe<\/strong><\/p>\n<p>Zombie Conga\u8fd9\u4e2a\u6e38\u620f\u662f\u4e3aiPhone\u521b\u5efa\u7684,\u6240\u4ee5\u6211\u4eec\u8981\u5c06\u6e38\u620f\u89c6\u56fe\u5c3a\u5bf8\u8bbe\u5b9a\u4e3a1136 x 640\u5927\u5c0f.<\/p>\n<p>\u7528Game\u89c6\u56fe\u5de6\u4e0a\u89d2\u7684\u4e0b\u62c9\u83dc\u5355\u6765\u6539\u53d8\u7eb5\u6a2a\u6bd4\u6216\u56fa\u5b9a\u5206\u8fa8\u7387,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1509\" rel=\"attachment wp-att-1509\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1509\" alt=\"game_view_ctrl_bar\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_ctrl_bar-300x22.png\" width=\"300\" height=\"22\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_ctrl_bar-300x22.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_ctrl_bar.png 450w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u4f9d\u636e\u7f16\u8f91\u5668\u76ee\u524dPlayersetting\u7684\u4e0d\u540c\u8bbe\u7f6e,\u8fd9\u4e2a\u4e0b\u62c9\u83dc\u5355\u4e5f\u5c06\u6709\u4e0d\u540c\u7684\u9009\u9879,\u5982\u679c\u91cc\u9762\u67091136 x 640\u8fd9\u4e2a\u5206\u8fa8\u7387\u9879,\u76f4\u63a5\u9009\u62e9\u5b83\u5c31\u53ef\u4ee5\u4e86.\u5982\u679c\u6ca1\u6709,\u6211\u4eec\u53ef\u4ee5\u5355\u51fb\u4e0b\u9762\u7684\u52a0\u53f7\u6309\u94ae,\u5982\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1510\" rel=\"attachment wp-att-1510\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1510\" alt=\"game_view_size_options\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_size_options.png\" width=\"196\" height=\"184\" \/><\/a><br \/>\n\u6e38\u620f\u89c6\u56fe\u5c3a\u5bf8\u9009\u9879<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fa\u5b9a\u5206\u8fa8\u7387\u5c3a\u5bf8\u8bbe\u5b9a\u5bbd\u9ad8\u4e3a1136 \u548c 640,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1511\" rel=\"attachment wp-att-1511\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1511\" alt=\"new_game_view_size\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/new_game_view_size.png\" width=\"228\" height=\"142\" \/><\/a><br \/>\n\u65b0\u6e38\u620f\u89c6\u56fe\u5c3a\u5bf8<\/p>\n<p>\u70b9\u51fb\u786e\u5b9a,\u7136\u540e\u540c\u6837\u5728\u4e0b\u62c9\u83dc\u5355\u4e2d\u9009\u62e9\u4f60\u8bbe\u5b9a\u7684\u65b0\u5206\u8fa8\u7387.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1450\" rel=\"attachment wp-att-1450\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1450\" alt=\"game_view_bad_camera\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_bad_camera-300x185.png\" width=\"300\" height=\"185\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_bad_camera-300x185.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_bad_camera.png 680w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u6ce8:\u4f60\u7684\u89c6\u56fe\u53ef\u80fd\u548c\u622a\u56fe\u4e0d\u592a\u4e00\u6837,\u56e0\u4e3aUnity\u4f1a\u6839\u636e\u5c4f\u5e55\u7a7a\u95f4\u6765\u4f9d\u7167\u6240\u9009\u7eb5\u6a2a\u6bd4\u6765\u8c03\u6574\u6e38\u620f\u89c6\u56fe\u7684\u5927\u5c0f.\u4e0d\u7ba1\u5b83\u591a\u5927\u7684\u7a97\u53e3,\u4f60\u90fd\u5e94\u8be5\u5728\u89c6\u56fe\u91cc\u770b\u5230\u548c\u622a\u56fe\u4e00\u6837\u7684\u573a\u666f\u56fe\u50cf.<\/p>\n<p>\u663e\u7136,\u73b0\u5728\u8fd9\u4e2a\u6837\u5b50\u662f\u9519\u8bef\u7684,\u73b0\u5728\u8fd9\u91cc\u6709\u4e09\u4e2a\u4e0d\u540c\u7684\u95ee\u9898,\u6211\u4eec\u9700\u8981\u4f9d\u6b21\u7ea0\u6b63\u5b83\u4eec:<br \/>\n\u573a\u666f\u89c6\u56fe\u7684Camera\u8bbe\u7f6e\u4e0d\u6b63\u786e,\u80cc\u666f\u4e0d\u80fd\u5b8c\u5168\u586b\u5145\u5230\u89c6\u56fe\u4e2d.<br \/>\n\u573a\u666f\u4e2d\u6e38\u620f\u5bf9\u8c61\u7684\u6e32\u67d3\u987a\u5e8f\u4e0d\u6b63\u786e,\u6240\u4ee5cat\u548cenemy\u90fd\u57cb\u5728\u4e86\u6c99\u571f\u91cc.<br \/>\n\u56fe\u50cf\u6548\u679c\u4e0d\u592a\u597d,\u8fd9\u4e2a\u57fa\u4e8e\u73b0\u5728\u7684\u76f8\u673a\u8bbe\u7f6e\u4f60\u6709\u53ef\u80fd\u8fd8\u770b\u4e0d\u51fa\u6765,\u4f46\u662f\u76f8\u4fe1\u6211\u8bf4\u7684,\u8d28\u91cf\u4e0d\u597d\u5c31\u662f\u4e0d\u597d,\u5bf9\u4e0d\u5bf9? \ud83d\ude42<\/p>\n<p>\u9996\u5148\u6211\u4eec\u6765\u4fee\u6b63Camera.<\/p>\n<p>\u4fee\u6b63\u76f8\u673aProjection<\/p>\n<p>\u57282D\u6e38\u620f\u4e2d,\u901a\u5e38\u5e0c\u671b\u76f8\u673a\u4f7f\u7528\u6b63\u4ea4\u89c6\u56fe\u800c\u4e0d\u662f\u900f\u89c6\u56fe.\u672c\u6559\u7a0b\u7684\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u63d0\u5230Unity\u9ed8\u8ba4\u662f\u4f7f\u7528\u900f\u89c6\u89c6\u56fe\u7684\u76f8\u673a.\u6211\u4eec\u5728Hierarchy\u89c6\u56fe\u4e2d\u9009\u62e9&#8221;Main Camera&#8221;,\u5728\u76f8\u673a\u7ec4\u4ef6\u4e2d,\u5c06\u6295\u5f71\u8bbe\u7f6e\u4e3a\u6b63\u4ea4\u6295\u5f71.\u5e76\u8c03\u6574\u8c03\u6574\u5b83Transform\u7ec4\u4ef6\u91cc\u7684Position\u4e3a(0,0,-10).\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1436\" rel=\"attachment wp-att-1436\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1436\" alt=\"camera_ortho_settings\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/camera_ortho_settings.png\" width=\"276\" height=\"288\" \/><\/a><\/p>\n<p>\u4f60\u7684Game\u89c6\u56fe\u73b0\u5728\u50cf\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1461\" rel=\"attachment wp-att-1461\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1461\" alt=\"ortho_game_view_bad_size\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/ortho_game_view_bad_size-300x188.png\" width=\"300\" height=\"188\" srcset=\"\/wp-content\/uploads\/2014\/02\/ortho_game_view_bad_size-300x188.png 300w, \/wp-content\/uploads\/2014\/02\/ortho_game_view_bad_size.png 552w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u73b0\u5728\u6548\u679c\u770b\u4e0a\u53bb\u4e0e\u900f\u89c6\u6295\u5f71\u6ca1\u4ec0\u4e48\u533a\u522b,\u7cbe\u7075\u4e0d\u53d7\u8ddd\u79bb\u76f8\u673a\u7684\u8fdc\u8fd1\u5f71\u54cd,\u90a3\u600e\u4e48\u653e\u5927\u80cc\u666f\u4f7f\u5176\u5145\u6ee1\u5c4f\u5e55\u5462?\u6211\u4eec\u63a8\u8350\u6539\u53d8Camera\u7684Size\u5c5e\u6027.<\/p>\n<p>Camera\u7684Size\u5b9a\u4e49\u4e86\u89c6\u56fe\u7684\u5c3a\u5bf8.\u5b83\u7684\u503c\u662f\u4ece\u89c6\u56fe\u4e2d\u5fc3\u5230\u89c6\u56fe\u9876\u90e8\u7684\u8ddd\u79bb.\u6362\u53e5\u8bdd\u8bf4\u8fd9\u4e2a\u503c\u7b49\u4e8e\u89c6\u56fe\u4e00\u534a\u9ad8\u5ea6.\u89c6\u56fe\u7684\u5bbd\u5ea6\u57fa\u4e8e\u89c6\u56fe\u7684\u957f\u5bbd\u6bd4\u8ba1\u7b97,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1427\" rel=\"attachment wp-att-1427\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1427\" alt=\"annotated_ortho_view\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/annotated_ortho_view-300x188.png\" width=\"300\" height=\"188\" srcset=\"\/wp-content\/uploads\/2014\/02\/annotated_ortho_view-300x188.png 300w, \/wp-content\/uploads\/2014\/02\/annotated_ortho_view.png 552w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u5728\u672c\u4f8b\u4e2d,\u6211\u4eec\u9700\u8981\u5c06\u80cc\u666f\u56fe\u7247\u4ece\u4e0a\u5230\u4e0b\u5b8c\u5168\u5360\u6ee1\u6574\u4e2a\u5c4f\u5e55,\u5e76\u5141\u8bb8\u5176\u6c34\u5e73\u6eda\u52a8.\u80cc\u666f\u56fe\u50cf\u7684\u9ad8\u5ea6\u662f640px,\u6211\u4eec\u53d6\u4e00\u534a,\u5373320px.\u4e0d\u8fc7\u8fd9\u5e76\u4e0d\u662f\u5b8c\u5168\u6b63\u786e\u7684.<br \/>\n\u5728Project\u89c6\u56fe\u91cc\u9009\u62e9background\u7684\u7236\u7ea7\u67e5\u770bImport Settings.<br \/>\n\u5728\u7cbe\u7075\u6e32\u67d3\u5668(Sprite Renderer)\u7684&#8221;\u50cf\u7d20\u5230\u5355\u4f4d(Pixels to Units)&#8221;\u9ed8\u8ba4\u503c\u662f100,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1465\" rel=\"attachment wp-att-1465\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1465\" alt=\"pixels_to_units\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/pixels_to_units.png\" width=\"274\" height=\"260\" \/><\/a><\/p>\n<p>\u5728Unity\u4e2d,&#8221;\u5355\u4f4d(Units)&#8221;\u5e76\u4e0d\u4e00\u5b9a\u5bf9\u5e94\u5230\u5c4f\u5e55\u4e0a\u7684\u50cf\u7d20.\u901a\u5e38\u7269\u4f53\u7684\u5927\u5c0f\u90fd\u662f\u76f8\u5bf9\u4e8e\u5f7c\u6b64\u7684,\u53ef\u4ee5\u5047\u8bbe\u5355\u4f4d\u4e3a\u4efb\u4f55\u8ba1\u91cf\u5355\u4f4d,\u59821 unit=1\u7c73.\u5bf9\u4e8e\u7cbe\u7075,Unity\u4ee5\u50cf\u7d20\u4e3a\u5355\u4f4d\u6765\u786e\u5b9a\u5927\u5c0f.<\/p>\n<p>\u4f8b\u5982,\u51c6\u5907\u5c06\u4e00\u4e2a500px\u5bbd\u5ea6\u7684\u56fe\u50cf\u5bfc\u6210\u7cbe\u7075.\u4e0b\u8868\u663e\u793a\u4e86\u5c06\u5b83\u7528\u4e0d\u540c\u7684&#8221;Pixels to Units&#8221;\u65f6\u6240\u5448\u73b0\u51fa\u7684\u7cbe\u7075\u5728X\u8f74\u5411\u4e0a\u7684\u5dee\u522b.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1466\" rel=\"attachment wp-att-1466\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1466\" alt=\"pixes_to_units_table\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/pixes_to_units_table-300x128.png\" width=\"300\" height=\"128\" srcset=\"\/wp-content\/uploads\/2014\/02\/pixes_to_units_table-300x128.png 300w, \/wp-content\/uploads\/2014\/02\/pixes_to_units_table.png 700w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u4e0d\u540c&#8221;\u50cf\u7d20\u5230\u5355\u4f4d(Pixels to Units)&#8221;\u7684\u5bf9\u6bd4\u56fe.<\/p>\n<p>background.png\u4e3a640\u9ad8,background\u7cbe\u7075\u7684&#8221;\u50cf\u7d20\u5230\u5355\u4f4d(Pixels to Units)&#8221;\u6bd4\u4f8b\u4e3a100,\u6240\u4ee5\u5728Hierarchy\u89c6\u56fe\u4e2d\u5b83\u5c06\u5448\u73b0\u4e3a6.4\u4e2aunits\u9ad8.\u6b63\u4ea4\u76f8\u673a\u7684Size\u5c5e\u6027\u503c\u662f\u5c4f\u5e55\u9ad8\u5ea6\u7684\u4e00\u534a,\u6240\u4ee5\u6211\u4eec\u8981\u8bbe\u7f6e\u76f8\u673a\u5c3a\u5bf8(Size)\u4e3a3.2\u4e2a\u5355\u4f4d,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1462\" rel=\"attachment wp-att-1462\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1462\" alt=\"ortho_size_fixed\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/ortho_size_fixed.png\" width=\"276\" height=\"154\" \/><\/a><\/p>\n<p>\u73b0\u5728\u80cc\u666f\u5df2\u7ecf\u6b63\u786e\u7684\u5145\u6ee1\u4e86Game\u89c6\u56fe\u4e2d,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1451\" rel=\"attachment wp-att-1451\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1451\" alt=\"game_view_good_camera\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_good_camera-300x188.png\" width=\"300\" height=\"188\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_good_camera-300x188.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_good_camera.png 550w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u6b63\u786e\u7684\u76f8\u673a\u8bbe\u7f6e\u4e0b\u7684Game\u89c6\u56fe<\/p>\n<p>\u73b0\u5728\u80cc\u666f\u56fe\u50cf\u663e\u793a\u6b63\u5e38\u4e86,\u4f60\u5c31\u53ef\u4ee5\u770b\u5230\u56fe\u50cf\u8d28\u91cf\u7684\u95ee\u9898\u4e86.\u4e0b\u9762\u4e24\u5f20\u56fe\u7247\u662f\u56fe\u7247\u5bf9\u6bd4:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1431\" rel=\"attachment wp-att-1431\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1431\" alt=\"bg_compressed_bad\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/bg_compressed_bad-300x59.png\" width=\"300\" height=\"59\" srcset=\"\/wp-content\/uploads\/2014\/02\/bg_compressed_bad-300x59.png 300w, \/wp-content\/uploads\/2014\/02\/bg_compressed_bad.png 688w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u5f53\u524d\u8bbe\u7f6e\u7684\u6d77\u6ee9<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1432\" rel=\"attachment wp-att-1432\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1432\" alt=\"bg_compressed_good_annotated\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/bg_compressed_good_annotated-300x59.png\" width=\"300\" height=\"59\" srcset=\"\/wp-content\/uploads\/2014\/02\/bg_compressed_good_annotated-300x59.png 300w, \/wp-content\/uploads\/2014\/02\/bg_compressed_good_annotated.png 688w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u6539\u53d8\u7eb9\u7406\u8bbe\u7f6e\u540e\u7684\u6d77\u6ee9<\/p>\n<p>\u4e0a\u9762\u8fd9\u4e2a\u95ee\u9898\u662f\u7531\u4e8e\u80cc\u666f\u7eb9\u7406\u5728\u5bfc\u5165\u65f6\u538b\u7f29\u5bfc\u81f4.\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6539\u53d8\u5bfc\u5165\u8bbe\u7f6e\u4fee\u6b63\u5b83.<\/p>\n<p>\u7ea0\u6b63\u5bfc\u5165\u8bbe\u7f6e<\/p>\n<p>\u5728Project\u89c6\u56fe\u9009\u62e9background\u7684\u7236\u7ea7\u518d\u6b21\u663e\u793a\u5bfc\u5165\u8bbe\u7f6e(Import Settings),\u8fd9\u6b21\u6211\u4eec\u770b\u5e95\u90e8\u7684\u9884\u89c8\u56fe.<br \/>\n\u8fd9\u4e2a\u9884\u89c8\u7a97\u53e3\u5c06\u663e\u793a\u7eb9\u7406\u7684\u5c3a\u5bf8,\u989c\u8272\u4fe1\u606f\u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5.\u6b63\u5982\u4e0b\u9762\u622a\u56fe\u4e2d\u6240\u770b\u5230\u7684\u5f53\u524d\u7eb9\u7406\u5927\u5c0f\u4e3a1024&#215;320\u50cf\u7d20,\u4f46background.png\u5b9e\u9645\u4e3a2048&#215;640\u50cf\u7d20,\u8fd9\u5c31\u610f\u5473\u7740Unity\u7f29\u5c0f\u4e8650%\u4ee5\u9002\u5e941024&#215;1024\u7eb9\u7406\u5c3a\u5bf8.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1434\" rel=\"attachment wp-att-1434\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1434\" alt=\"bg_preview_with_default_settings\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/bg_preview_with_default_settings-300x206.png\" width=\"300\" height=\"206\" srcset=\"\/wp-content\/uploads\/2014\/02\/bg_preview_with_default_settings-300x206.png 300w, \/wp-content\/uploads\/2014\/02\/bg_preview_with_default_settings.png 316w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u80cc\u666f\u7eb9\u7406\u9ed8\u8ba4\u8bbe\u7f6e\u9884\u89c8<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u8d28\u91cf\u95ee\u9898,\u5728\u5bfc\u5165\u8bbe\u7f6e\u7684\u5e95\u90e8\u9009\u62e9\u5982\u56fe\u6240\u793a\u7684\u6700\u5927\u5c3a\u5bf8\u548c\u683c\u5f0f\u8bbe\u7f6e:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1457\" rel=\"attachment wp-att-1457\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1457\" alt=\"import_settings_default_tab\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/import_settings_default_tab-300x67.png\" width=\"300\" height=\"67\" srcset=\"\/wp-content\/uploads\/2014\/02\/import_settings_default_tab-300x67.png 300w, \/wp-content\/uploads\/2014\/02\/import_settings_default_tab.png 310w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u5bfc\u5165\u8bbe\u7f6e\u9ed8\u8ba4\u9009\u9879\u5361<\/p>\n<p>\u6700\u5927\u5c3a\u5bf8(Max Size)\u5b9a\u4e49\u751f\u6210\u7eb9\u7406\u6240\u5141\u8bb8\u7684\u6700\u5927\u5c3a\u5bf8,\u5b83\u662f\u4e00\u4e2a\u6b63\u65b9\u5f62,\u9ed8\u8ba4\u4e3a1024px.\u540c\u65f6\u56fe\u50cf\u6df1\u5ea6\u9ed8\u8ba4\u4e3a\u538b\u7f29\u7684(Compressed).<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4e3a\u4e0d\u540c\u76ee\u6807\u5e73\u53f0\u8bbe\u7f6e\u4e0d\u540c\u7684\u503c(\u4f8b\u5982iOS,\u7f51\u4e0a\u53caAndroid\u4e0a),\u4f46\u672c\u4f8b\u4e2d\u6211\u4eec\u53ea\u5904\u7406\u9ed8\u8ba4(Default)\u9009\u9879\u5361.<\/p>\n<p>\u5728\u9ed8\u8ba4(Default)\u9009\u9879\u5361\u4e2d,\u6539\u6700\u5927\u5c3a\u5bf8(Max Size)\u52302040\u548c\u70b9\u51fb\u5e94\u7528(Apply)\u6309\u94ae.\u5bfc\u5165\u8bbe\u7f6e\u73b0\u5728\u5e94\u8be5\u662f\u8fd9\u6837\u7684:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1429\" rel=\"attachment wp-att-1429\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1429\" alt=\"background_import_settings_a\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/background_import_settings_a-300x268.png\" width=\"300\" height=\"268\" srcset=\"\/wp-content\/uploads\/2014\/02\/background_import_settings_a-300x268.png 300w, \/wp-content\/uploads\/2014\/02\/background_import_settings_a.png 320w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u9a6c\u4e0a\u4f60\u5c31\u4f1a\u770b\u5230\u65e0\u8bba\u662f\u573a\u666f\u89c6\u56fe\u8fd8\u662f\u6e38\u620f\u89c6\u56fe,\u753b\u8d28\u90fd\u5f88\u597d.\u8fd9\u662f\u56e0\u4e3a\u80cc\u666f\u56fe\u50cf\u7528\u4e86\u8f83\u5c11\u7684\u538b\u7f29.\u4e0b\u56fe\u663e\u793a\u4e86Game\u89c6\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1454\" rel=\"attachment wp-att-1454\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1454\" alt=\"game_view_with_correct_settings\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_with_correct_settings-300x185.png\" width=\"300\" height=\"185\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_with_correct_settings-300x185.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_with_correct_settings.png 684w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u7528\u4e86\u6b63\u786e\u8bbe\u7f6e\u7684\u6e38\u620f\u89c6\u56fe<\/p>\n<p>\u5728Inspector\u9884\u89c8\u56fe\u4e2d\u6211\u4eec\u80fd\u770b\u5230\u80cc\u666f\u7eb9\u7406\u73b0\u5728\u5360\u75280.6MB\u5185\u5b58,\u8fdc\u9ad8\u4e8e\u4e4b\u524d\u7684160KB:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1426\" rel=\"attachment wp-att-1426\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1426\" alt=\"annotated_bg_preview\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/annotated_bg_preview-300x207.png\" width=\"300\" height=\"207\" srcset=\"\/wp-content\/uploads\/2014\/02\/annotated_bg_preview-300x207.png 300w, \/wp-content\/uploads\/2014\/02\/annotated_bg_preview.png 318w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u589e\u5927\u7eb9\u7406\u5c3a\u5bf8\u5bfc\u81f4\u7eb9\u7406\u5185\u5b58\u5360\u7528\u589e\u52a0\u4e864\u500d(\u9884\u89c8\u56fe\u7684\u6570\u5b57\u662f\u56db\u820d\u4e94\u5165\u7684).<br \/>\n\u5bf9\u4e8e\u4e00\u4e9b\u7eb9\u7406,\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5355\u72ec\u8c03\u6574Format\u503c\u4ee5\u63d0\u9ad8\u9700\u8981\u7684\u8272\u5f69\u8d28\u91cf,\u4f46\u662f\u8fd9\u4f1a\u8fdb\u4e00\u6b65\u589e\u5927\u5185\u5b58\u5360\u7528.\u4f8b\u5982,\u5982\u679c\u4f60\u5c1d\u8bd5\u6539\u80cc\u666f\u683c\u5f0f\u4e3a16bits,\u4f60\u5c06\u770b\u5230\u7eb9\u7406\u5185\u5b58\u5360\u7528\u589e\u957f\u52302.5MB,\u6539\u6210\u771f\u8272\u5f69(Truecolor)\u5c06\u4f1a\u5360\u75283.8MB.<br \/>\n\u4f46\u662f,\u4f60\u770b\u4e0b\u9762\u8fd9\u4e24\u4e2a\u4e0d\u540c\u7248\u672c\u7684\u80cc\u666f\u6548\u679c,\u4f1a\u53d1\u73b0\u7528Compressed(\u538b\u7f29)\u8bbe\u7f6e\u548cTruecolor(\u771f\u5f69\u8272)\u6bd4\u8d77\u6765\u5dee\u4e0d\u591a:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1433\" rel=\"attachment wp-att-1433\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1433\" alt=\"bg_compressed_good\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/bg_compressed_good-300x59.png\" width=\"300\" height=\"59\" srcset=\"\/wp-content\/uploads\/2014\/02\/bg_compressed_good-300x59.png 300w, \/wp-content\/uploads\/2014\/02\/bg_compressed_good.png 688w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u538b\u7f29\u7eb9\u7406(Compressed)\u7684\u80cc\u666f<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1435\" rel=\"attachment wp-att-1435\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1435\" alt=\"bg_truecolor\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/bg_truecolor-300x59.png\" width=\"300\" height=\"59\" srcset=\"\/wp-content\/uploads\/2014\/02\/bg_truecolor-300x59.png 300w, \/wp-content\/uploads\/2014\/02\/bg_truecolor.png 688w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u771f\u5f69\u8272(Truecolor)\u7684\u80cc\u666f<\/p>\n<p>\u7531\u4e8e\u538b\u7f29\u540e\u7684\u80cc\u666f\u770b\u8d77\u6765\u5f88\u4e0d\u9519,\u540c\u65f6\u8282\u7701\u5f88\u591a\u5185\u5b58\u5360\u7528,\u90a3\u4e48\u6211\u4eec\u5c31\u9009\u62e9\u538b\u7f29\u683c\u5f0f.\u73b0\u5728\u80cc\u666f\u548c\u76f8\u673a\u8bbe\u7f6e\u770b\u8d77\u6765\u90fd\u6ca1\u95ee\u9898\u4e86,\u6211\u4eec\u9700\u8981\u627e\u5230 old lady\u548ccat.<\/p>\n<p>\u63a7\u5236\u7ed8\u56fe\u987a\u5e8f(Controlling Draw Order)<\/p>\n<p>\u56e0\u4e3acat\u548cenemy\u88ab\u7ed8\u5236\u5728\u4e86\u80cc\u666f\u540e\u9762,\u6240\u4ee5\u6211\u4eec\u770b\u4e0d\u5230\u5b83\u4eec.\u53ef\u4ee5\u8c03\u6574\u6e38\u620f\u5bf9\u8c61Z\u8f74\u7684\u4f4d\u7f6e,\u4f7f\u5bf9\u8c61\u9760\u8fd1\u76f8\u673a,\u6211\u89c9\u5f97\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u597d\u7684\u65b9\u5f0f,\u7136\u800cUnity\u73b0\u5728\u652f\u6301\u56fe\u5c42\u6392\u5e8f(Sorting Layers),\u66f4\u9002\u5408\u5904\u7406\u8fd9\u4e2a\u95ee\u9898.<\/p>\n<p>\u5728Hierarchy\u89c6\u56fe\u9009\u62e9cat,\u628a\u7cbe\u7075\u6e32\u67d3\u5668\u7684\u5c42\u6392\u5e8f(Sorting Layer)\u8bbe\u7f6e\u4e3aDefault,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1442\" rel=\"attachment wp-att-1442\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1442\" alt=\"default_sorting_layer\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/default_sorting_layer.png\" width=\"274\" height=\"120\" \/><\/a><\/p>\n<p>\u70b9\u51fbSorting Layer\u4e0b\u62c9\u6846,\u4f60\u9879\u76ee\u6240\u6709\u5c42\u90fd\u5c06\u5448\u73b0\u5728\u8fd9\u91cc,\u73b0\u5728\u53ea\u6709\u9ed8\u8ba4\u5b9a\u4e49\u7684Default\u5c42.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1494\" rel=\"attachment wp-att-1494\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1494\" alt=\"tags_and_layers_editor\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/tags_and_layers_editor.png\" width=\"274\" height=\"180\" \/><\/a><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6709&#8221;Add Sorting Layer\u2026. &#8220;\u9009\u9879,\u70b9\u51fb+\u53f7,\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6392\u5e8f\u56fe\u5c42,\u547d\u540d\u4e3acat,\u540c\u6837\u7684\u518d\u521b\u5efa\u4e24\u4e2a\u5c42,\u5206\u522b\u662fEnemies\u548cZombie.\u73b0\u5728\u770b\u8d77\u6765\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1473\" rel=\"attachment wp-att-1473\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1473\" alt=\"sorting_layers_defined\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sorting_layers_defined.png\" width=\"274\" height=\"226\" \/><\/a><\/p>\n<p>\u8fd9\u4e9b\u5c42\u5c06\u5b9a\u4e49\u7ed8\u5236\u987a\u5e8f,Layer 0,\u540d\u5b57\u662fDefault,\u662f\u5728\u6700\u8fdc\u6700\u540e\u9762\u7684,Layer 1,\u540d\u5b57\u662fCats,\u5728\u5b83\u7684\u524d\u9762.<br \/>\n\u73b0\u5728,\u5df2\u7ecf\u6dfb\u52a0\u7684\u6bcf\u4e2a\u6e38\u620f\u7269\u4f53\u90fd\u662f\u88ab\u8bbe\u5b9a\u4e3aDefault\u5c42.\u80cc\u666f\u56fe\u50cf\u5728\u8fd9\u5c42\u662f\u6ca1\u95ee\u9898\u7684,\u56e0\u4e3a\u5b83\u5728\u6700\u540e\u9762,\u6240\u4ee5\u6211\u4eec\u8981\u66f4\u6539\u5176\u5b83\u7cbe\u7075\u7684\u5c42.<br \/>\n\u5728Hierarchy\u89c6\u56fe\u9009\u62e9cat\u7684Sorting Layer\u4e3aCats.\u4f60\u4f1a\u5728\u573a\u666f\u89c6\u56fe\u548c\u6e38\u620f\u89c6\u56fe\u91cc\u7acb\u523b\u770b\u5230cat\u51fa\u73b0\u4e86.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1440\" rel=\"attachment wp-att-1440\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1440\" alt=\"cat_sorting_layer\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/cat_sorting_layer.png\" width=\"276\" height=\"118\" \/><\/a><br \/>\n\u5728\u65b0\u56fe\u5c42\u7684cat<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1453\" rel=\"attachment wp-att-1453\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1453\" alt=\"game_view_with_cat_visible\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_with_cat_visible-300x182.png\" width=\"300\" height=\"182\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_with_cat_visible-300x182.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_with_cat_visible.png 692w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u573a\u666f\u4e2d\u80fd\u770b\u89c1cat\u4e86<\/p>\n<p>\u5728Hierarchy\u89c6\u56fe\u4e2d\u9009\u62e9enemy\u7684Sorting Layer\u5230Enemies\u5c42.\u8fd9\u6837\u4ee5\u6765,\u4f60\u4f1a\u770b\u5230\u8001\u592a\u592a(old lady)\u663e\u73b0\u5728\u732b\u7684\u524d\u9762,\u732b\u4f1a\u4e0d\u4f1a\u7eca\u5012\u6b27\u5df4\u6851?\u7ba1\u5b83\u5462&#8230;<\/p>\n<p>\u6700\u540e,\u5c06zombie\u7684\u5c42\u8bbe\u5b9a\u4e3aZombie,\u786e\u4fdd\u6240\u6709\u7cbe\u7075\u90fd\u5728\u80cc\u666f\u4e4b\u4e0a\u6e32\u67d3,\u73b0\u5728\u89c6\u56fe\u770b\u8d77\u6765\u50cf\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1455\" rel=\"attachment wp-att-1455\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1455\" alt=\"game_view_with_good_draw_order\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_with_good_draw_order-300x182.png\" width=\"300\" height=\"182\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_with_good_draw_order-300x182.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_with_good_draw_order.png 692w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u6b63\u786e\u7ed8\u5236\u987a\u5e8f\u7684\u6e38\u620f\u89c6\u56fe<\/p>\n<p>\u6ce8:\u7cbe\u7075\u6e32\u67d3\u5668\u540c\u6837\u6709\u4e2a\u540d\u4e3aOrder\u7684\u5c5e\u6027,\u4f7f\u7528\u5b83\u53ef\u4ee5\u8c03\u6574\u76f8\u540c\u6392\u5e8f\u5c42\u4e2d\u7cbe\u7075\u95f4\u987a\u5e8f.<\/p>\n<p>\u5728\u672c\u4f8b\u4e2d\u6211\u4eec\u4e0d\u9700\u8981\u8c03\u6574Order\u5c5e\u6027,\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u5728\u540c\u4e00\u4e2a\u5c42\u91cc\u653e\u4e0d\u540c\u7684\u7cbe\u7075.\u4ece\u6211\u7684\u6d4b\u8bd5\u7ed3\u679c\u6765\u770b,Unity\u5728\u6dfb\u52a0\u6dfb\u52a0\u4e00\u4e2a\u7cbe\u7075\u5230\u4e00\u4e2a\u5c42\u7684\u65f6\u5019,\u5c06\u603b\u4f1a\u628a\u6700\u65b0\u7684\u7cbe\u7075\u753b\u5728\u5c42\u5185\u65e7\u7cbe\u7075\u7684\u524d\u9762.<\/p>\n<p><strong>\u7ed9\u7cbe\u7075\u7f16\u7a0b<\/strong><\/p>\n<p>\u73b0\u5728\u6c99\u6ee9\u4e0a\u6563\u843d\u7740\u4e00\u4e9b\u7cbe\u7075,\u5b83\u4eec\u6ca1\u6709\u4efb\u4f55\u52a8\u4f5c.\u6559\u7a0b\u8fd9\u90e8\u5206\u6211\u4eec\u5c06\u5b8c\u6210\u5b83\u4eec\u7684\u63a7\u5236,\u6211\u4eec\u4f1a\u7f16\u5199\u4e24\u6bb5\u811a\u672c,\u4e00\u4e2a\u662f\u50f5\u5c38\u7684\u52a8\u753b,\u53e6\u5916\u4e00\u4e2a\u662f\u5141\u8bb8\u73a9\u5bb6\u63a7\u5236\u50f5\u5c38\u7684\u79fb\u52a8,\u5176\u4f59\u7684\u7b49\u4f60\u5b66\u4f1a\u4e86\u81ea\u5df1\u5199\u5427&#8230;<\/p>\n<p>\u6ce8:\u6211\u4eec\u7528C#(\u53d1\u97f3\u4e3a&#8221;see-sharp&#8221;)\u5199\u811a\u672c,\u5b83\u5f88\u5bb9\u6613,\u5982\u679c\u4f60\u559c\u6b22,\u4e5f\u53ef\u4ee5\u7528JavaScript\u6765\u5199.<\/p>\n<p><strong>\u7cbe\u7075\u52a8\u753b(Animating Sprites)<\/strong><\/p>\n<p>\u9996\u5148\u6211\u4eec\u6dfb\u52a0\u4e00\u4e2a\u811a\u672c\u6765\u5236\u4f5c\u50f5\u5c38\u7684\u52a8\u753b.\u5728Hierarchy\u89c6\u56fe\u9009\u62e9zombie\u5e76\u7ed9\u5b83\u65b0\u5efa\u4e2a\u811a\u672c,\u547d\u540d\u4e3a&#8221;ZombieAnimator&#8221;.\u4e0b\u9762\u52a8\u753b\u6f14\u793a\u4e86\u5177\u4f53\u6b65\u9aa4:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1424\" rel=\"attachment wp-att-1424\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1424\" alt=\"add_script_steps\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/add_script_steps-135x300.gif\" width=\"135\" height=\"300\" \/><\/a><\/p>\n<p>\u5728MonoDevelop\u4e2d\u6253\u5f00ZombieAnimator.cs,\u4e00\u822c\u60c5\u51b5\u4e0b\u5728Unity\u53cc\u51fbZombieAnimator\u6587\u4ef6\u5c31\u53ef\u4ee5\u6253\u5f00\u4e86.\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1487\" rel=\"attachment wp-att-1487\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1487\" alt=\"spriteanimator_in_inspector\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/spriteanimator_in_inspector.png\" width=\"274\" height=\"38\" \/><\/a><br \/>\nInspector\u89c6\u56fe\u4e2d\u7684SpriteAnimator\u811a\u672c<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1488\" rel=\"attachment wp-att-1488\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1488\" alt=\"spriteanimator_in_project\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/spriteanimator_in_project-300x78.png\" width=\"300\" height=\"78\" srcset=\"\/wp-content\/uploads\/2014\/02\/spriteanimator_in_project-300x78.png 300w, \/wp-content\/uploads\/2014\/02\/spriteanimator_in_project.png 690w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nProject\u89c6\u56fe\u4e2d\u7684SpriteAnimator<\/p>\n<p>\u6211\u4eec\u8981\u8ba9\u50f5\u5c38\u8fdb\u884c\u7b80\u5355\u7684\u884c\u8d70\u52a8\u753b,\u9700\u8981\u7cbe\u7075\u52a8\u4f5c\u8868\u548c\u4e00\u4e2a\u5faa\u73af\u901f\u5ea6.\u6211\u4eec\u5b9a\u4e49\u4e24\u4e2a\u516c\u5171\u53d8\u91cf\u5230\u811a\u672c\u4e2d:<\/p>\n<p><code>public Sprite[] sprites;<br \/>\npublic float framesPerSecond;<\/code><\/p>\n<p>\u6ce8:\u5728C#\u4e2d\u53d8\u91cf\u5b9a\u4e49\u5728\u6240\u6709\u5927\u62ec\u53f7\u4e4b\u5916,\u6807\u5fd7\u7740\u5b83\u662f\u5b9a\u4e49\u5728\u7c7b\u4e4b\u5185,\u6240\u6709\u51fd\u6570\u4e4b\u5916.\u8fd9\u4e0d\u7528\u7279\u522b\u7406\u89e3\u660e\u767d,\u901a\u5e38\u5c06\u5b83\u653e\u5728\u7c7b\u7684\u9876\u90e8,\u5373\u4efb\u4f55\u51fd\u6570\u5b9a\u4e49\u4e4b\u524d.<\/p>\n<p>\u516c\u5171\u53d8\u91cf\u5c06\u5728Unity\u7684\u7f16\u8f91\u5668\u4e2d\u66b4\u9732\u51fa\u6765,\u6240\u4ee5\u4f60\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u5b83\u4eec\u7684\u503c\u800c\u4e0d\u7528\u6539\u53d8\u4ee3\u7801,\u54ea\u6015\u662f\u8fd0\u884c\u7684\u65f6\u5019!\u8fd9\u4e2a\u7279\u6027\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\u5f02\u5e38\u65b9\u4fbf.<\/p>\n<p>\u901a\u8fc7\u5206\u914d\u4e0d\u540c\u7684\u7cbe\u7075\u7ed9SpriteRenderer\u7ec4\u4ef6\u6765\u6e32\u67d3\u52a8\u753b.\u800c\u4e0d\u662f\u5728Update\u4e2d\u8c03\u7528\u52a8\u753b,\u6211\u4eec\u8981\u5728\u811a\u672c\u5f00\u59cb\u8fd0\u884c\u65f6\u7ed9\u5b83\u7f13\u5b58\u4e2a\u5b9e\u4f8b\u53d8\u91cf.<\/p>\n<p>\u6211\u4eec\u6dfb\u52a0\u4e00\u4e2a\u79c1\u6709\u53d8\u91cf\u5230ZombieAnimator:<br \/>\n<code>private SpriteRenderer spriteRenderer;<\/code><\/p>\n<p>\u79c1\u6709\u53d8\u91cf\u662f\u4e0d\u4f1a\u66b4\u9732\u5728Unity\u7f16\u8f91\u5668\u4e2d\u7684,\u6211\u4eec\u5728Start\u4e2d\u521d\u59cb\u8fd9\u4e2a\u53d8\u91cf:<\/p>\n<p><code>spriteRenderer = renderer as SpriteRenderer;<\/code><\/p>\n<p>\u811a\u672c\u5b50\u7c7bMonoBehaviour\u53ef\u4ee5\u83b7\u5f97\u53d8\u91cf\u540c\u540d\u7684\u6e32\u67d3\u5668.\u5bf9\u4e8e\u663e\u793a\u7cbe\u7075\u7684\u6e38\u620f\u5bf9\u8c61,\u6e32\u67d3\u5668\u5c06\u662fSpriteRenderer.<\/p>\n<p>\u6ce8:\u53ef\u4ee5\u5728\u811a\u672c\u91cc\u76f4\u63a5\u5f15\u7528\u5e38\u89c1\u7684\u5bf9\u8c61,\u6bd4\u8f83\u5e38\u89c1\u7684\u5982\u6e38\u620f\u5bf9\u8c61\u7684Transform,\u573a\u666f\u7684main Camera.<\/p>\n<p>\u6211\u4eec\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\u5728Update\u4e2d:<br \/>\n<code>int index = (int)(Time.timeSinceLevelLoad * framesPerSecond);<br \/>\nindex = index % sprites.Length;<br \/>\nspriteRenderer.sprite = sprites[ index ];<\/code><\/p>\n<p>\u5173\u5361\u8f7d\u5165\u5230\u5f53\u524d\u7684\u65f6\u95f4\u79d2\u6570 (\u66f4\u591a\u4fe1\u606f\u8bf7\u67e5\u9605\u6587\u6863\u7684Time\u7c7b)\u548c\u6bcf\u79d2\u6e32\u67d3\u7684\u5e27\u6570\u76f8\u4e58.\u5982\u679c\u52a8\u753b\u5e27\u662f\u5b58\u50a8\u5728\u4e00\u4e2a\u65e0\u9650\u957f\u7684\u6570\u7ec4\u91cc,\u5f97\u51fa\u7684\u6570\u5c31\u662f\u6570\u7ec4\u4e2d\u6210\u5458\u7684\u7d22\u5f15\u6570.<\/p>\n<p>\u4f46\u662f\u4f60\u77e5\u9053\u6570\u7ec4\u6210\u5458\u4e0d\u4f1a\u662f\u65e0\u9650\u6570\u91cf\u7684,\u5f53\u52a8\u753b\u5e27\u6570\u7ec4\u64ad\u653e\u4e00\u904d\u540e\u4f60\u9700\u8981\u5faa\u73af\u56de\u5230\u5f00\u59cb,\u901a\u8fc7\u6267\u884c\u6a21\u6570(%)\u64cd\u4f5c,\u5373\u505a\u4e24\u4e2a\u6570\u5b57\u4e4b\u95f4\u7684\u6574\u9664\u53d6\u4f59.\u6362\u53e5\u8bdd\u8bf4\u4f60\u5c06\u5f97\u52300~\u6570\u7ec4\u603b\u6210\u5458\u6570\u4e4b\u95f4\u7684\u7d22\u5f15\u6765\u63a7\u5236\u52a8\u753b\u5e27\u7684\u64ad\u653e.\u5199\u5b8c\u4e0a\u9762\u811a\u672c\u540e\u4fdd\u5b58,\u7136\u540e\u5207\u6362\u56deUnity.\u5728Hierarchy\u89c6\u56fe\u9009\u62e9zombie\u4f1a\u770b\u5230Zombie Animator\u811a\u672c\u7ec4\u4ef6\u5c06\u663e\u793a\u521a\u624d\u5199\u7684\u4e24\u4e2a\u516c\u5171\u53d8\u91cf.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1467\" rel=\"attachment wp-att-1467\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1467\" alt=\"public_variables\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/public_variables.png\" width=\"274\" height=\"74\" \/><\/a><\/p>\n<p>\u7cbe\u7075\u6570\u7ec4\u5b57\u6bb5\u91cc\u9762\u6ca1\u6709\u5185\u5bb9,\u6211\u4eec\u9700\u8981\u6309\u7167\u5982\u4e0b\u987a\u5e8f\u6dfb\u52a0\u7cbe\u7075\u5e93\u5230\u6570\u7ec4\u91cc:zombie_0, zombie_1, zombie_2, zombie_3, zombie_2, zombie_1,\u6211\u6700\u559c\u6b22\u7684\u505a\u6cd5\u662f\u5728Hierarchy\u89c6\u56fe\u91cc\u9009\u62e9zombie,\u5728Inspector\u89c6\u56fe\u53f3\u4e0a\u89d2\u70b9\u51fb\u9501\u5934\u56fe\u6807,\u8fd9\u6837zombie\u7684Inspector\u9762\u677f\u5c06\u4f1a\u4e00\u76f4\u4fdd\u6301\u663e\u793a\u72b6\u6001,\u5373\u4f7f\u4f60\u9009\u62e9\u5176\u5b83\u5bf9\u8c61,\u5b83\u4f9d\u65e7\u4f1a\u663e\u793a.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1458\" rel=\"attachment wp-att-1458\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1458\" alt=\"inspector_locked\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/inspector_locked.png\" width=\"274\" height=\"58\" \/><\/a><\/p>\n<p>\u5728Project\u89c6\u56fe\u4e2d\u5c55\u5f00zombie\u7eb9\u7406,\u5355\u51fbzombie_0\u4ee5\u9009\u4e2d\u5b83,\u7136\u540e\u6309\u4f4fshift\u952e\u518d\u70b9\u51fbzombie_3\u6765\u9009\u62e94\u4e2a\u50f5\u5c38\u7cbe\u7075.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1491\" rel=\"attachment wp-att-1491\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1491\" alt=\"sprites_array_plus_icon\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprites_array_plus_icon.png\" width=\"274\" height=\"92\" \/><\/a><\/p>\n<p>\u62d6\u62fd\u9f20\u6807,\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u7eff\u8272\u7684\u52a0\u53f7\u7684\u5149\u6807,\u62fd\u5230\u7cbe\u7075\u6570\u7ec4\u90a3\u91cc,\u8fd9\u65f6\u53ef\u4ee5\u770b\u5230\u6240\u9009\u9879\u90fd\u52a0\u5230\u4e86\u7cbe\u7075\u6570\u7ec4\u91cc.\u73b0\u5728Zombie Animator\u811a\u672c\u7ec4\u4ef6\u770b\u8d77\u6765\u5e94\u8be5\u662f\u8fd9\u6837\u7684:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1490\" rel=\"attachment wp-att-1490\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1490\" alt=\"sprites_array_partial\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprites_array_partial.png\" width=\"276\" height=\"164\" \/><\/a><\/p>\n<p>\u7136\u540e\u53ea\u9009\u62e9zombie_2\u4ee5\u540c\u6837\u7684\u65b9\u5f0f\u8ffd\u52a0\u5230\u6570\u7ec4\u91cc,\u518d\u8ffd\u52a0\u4e2azombie_1,\u8fd9\u65f6\u7cbe\u7075\u6570\u7ec4\u5c06\u5305\u542b\u6b63\u786e\u987a\u5e8f\u7684\u516d\u4e2a\u5143\u7d20,\u5c31\u50cf\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1489\" rel=\"attachment wp-att-1489\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1489\" alt=\"sprites_array_full\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprites_array_full.png\" width=\"274\" height=\"200\" \/><\/a><br \/>\n\u7cbe\u7075\u6570\u7ec4\u4e0e\u516d\u4e2a\u5143\u7d20<\/p>\n<p>\u518d\u6b21\u70b9\u51fb\u9501\u6309\u94ae\u89e3\u9501,\u5982\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1459\" rel=\"attachment wp-att-1459\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1459\" alt=\"inspector_unlocked\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/inspector_unlocked.png\" width=\"274\" height=\"58\" \/><\/a><\/p>\n<p>Inspector\u89c6\u56fe\u89e3\u9501<\/p>\n<p>\u6700\u540e,\u8bbe\u7f6eFrames Per Second\u523010,\u50cf\u4e0b\u9762\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1500\" rel=\"attachment wp-att-1500\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1500\" alt=\"zombie_frames_per_second\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_frames_per_second.png\" width=\"276\" height=\"200\" \/><\/a><\/p>\n<p>\u8fd0\u884c\u4e00\u4e0b\u6e38\u620f,\u4f60\u4f1a\u770b\u5230\u53ef\u6015\u7684\u50f5\u5c38&#8230;<\/p>\n<p>\u6ce8:\u4f60\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u6839\u636e\u81ea\u5df1\u5fc3\u60c5\u8c03\u6574 Frames Per Second\u6765\u627e\u5230\u4e00\u4e2a\u5408\u9002\u7684\u901f\u5ea6,\u4f46Unity\u505c\u6b62\u64ad\u653e\u540e\u4f1a\u91cd\u7f6e\u8fd9\u4e2a\u8c03\u6574\u7684\u503c,\u56e0\u6b64\u4f60\u8981\u505c\u4e0b\u65f6\u4e00\u5b9a\u8981\u8bb0\u5f55\u4e00\u4e0b\u8fd9\u4e2a\u503c\u5728\u8d4b\u5230 Frames Per Second\u4e0a.<\/p>\n<p>\u73b0\u5728\u50f5\u5c38\u5df2\u7ecf\u590d\u6d3b\u4e86,\u4e0b\u4e00\u8282\u6211\u4eec\u8981\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u63a7\u5236\u5668\u811a\u672c\u8ba9\u5b83\u884c\u8d70\u8d77\u6765.<\/p>\n<p>\u63a7\u5236\u7cbe\u7075\u8fd0\u52a8<\/p>\n<p>\u5728Hierarchy\u89c6\u56fe\u4e2d\u9009\u62e9zombie\u5e76\u6dfb\u52a0\u4e00\u4e2a\u65b0C#\u811a\u672c,\u547d\u540d\u4e3a&#8221;ZombieController&#8221;,\u4f60\u53ef\u80fd\u8981\u4e00\u4e2a\u5e74\u8001\u7684\u8fc8\u7740\u6c89\u91cd\u6b65\u4f10\u7684\u50f5\u5c38,\u4e5f\u6216\u8005\u8981\u4e00\u4e2a\u6bd4\u8f83\u5e74\u8f7b\u6709\u6d3b\u529b\u7684\u50f5\u5c38,\u53ef\u4ee5\u901a\u8fc7\u79fb\u52a8\u901f\u5ea6\u6765\u8c03\u6574\u5b83\u4eec\u7684\u59ff\u6001,\u4fbf\u4e8e\u6211\u4eec\u5fae\u8c03,\u6211\u4eec\u5c06\u5b83\u5199\u4e3a\u516c\u5171\u53d8\u91cf.<\/p>\n<p>\u6253\u5f00ZombieController.cs\u811a\u672c\u5e76\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801:<\/p>\n<p><code>public float moveSpeed;<\/code><\/p>\n<p>moveSpeed\u5c06\u5b58\u50a8\u4e00\u4e2aunits\u6570,\u8fd9\u4e2a\u5355\u4f4d\u4e0d\u662f\u50cf\u7d20,\u800c\u662f\u50f5\u5c38\u6bcf\u79d2\u79fb\u52a8\u7684\u901f\u5ea6.\u56e0\u4e3a\u73b0\u5728\u7cbe\u7075\u662f\u4e00\u4e2a\u5355\u4f4d\u4e3a100\u4e2a\u50cf\u7d20,\u6240\u4ee5\u8fd9\u4e2a\u503c\u53ef\u80fd\u9700\u8981\u76f8\u5f53\u5c0f.<\/p>\n<p>\u6b63\u5982\u4e0b\u9762\u7684\u52a8\u753b,\u8981\u505a\u5f53\u7528\u6237\u70b9\u51fb\u9f20\u6807\u540e,\u50f5\u5c38\u6cbf\u7740\u76f4\u7ebf\u8d70\u5230\u9f20\u6807\u7684\u90a3\u4e2a\u70b9(\u6216\u8fd9\u7528\u6237\u662f\u6309\u4f4f\u9f20\u6807\u540c\u65f6\u62d6\u62fd\u9f20\u6807\u6765\u6539\u53d8\u50f5\u5c38\u65b0\u7684\u4f4d\u7f6e).<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1504\" rel=\"attachment wp-att-1504\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1504\" alt=\"zombie_pacing\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_pacing-300x85.gif\" width=\"300\" height=\"85\" \/><\/a><\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1499\" rel=\"attachment wp-att-1499\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1499\" alt=\"zombie_circles\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_circles-300x271.gif\" width=\"300\" height=\"271\" \/><\/a><\/p>\n<p>\u5e73\u65f6\u5f88\u53ef\u80fd\u4e0d\u4f1a\u5728\u6bcf\u4e00\u5e27\u90fd\u5f97\u5230\u8f93\u5165\u4e8b\u4ef6,\u6240\u4ee5\u5f53\u50f5\u5c38\u76ee\u7684\u65b9\u5411\u6539\u53d8\u65f6\u6211\u4eec\u9700\u8981\u5b58\u50a8\u50f5\u5c38\u7684\u76ee\u7684\u5730\u65b9\u5411.\u8981\u505a\u5230\u8fd9\u4e00\u70b9,\u6211\u4eec\u8981\u8ba1\u7b97\u51fa\u6307\u5411\u50f5\u5c38\u884c\u8d70\u65b9\u5411\u7684normalized\u5411\u91cf(\u957f\u5ea6\u4e3a1\u7684\u5411\u91cf).<\/p>\n<p>\u6dfb\u52a0\u5982\u4e0b\u53d8\u91cf\u5230ZombieController\u4e2d:<\/p>\n<p><code>private Vector3 moveDirection;<\/code><\/p>\n<p>\u867d\u7136\u6211\u4eec\u73b0\u5728\u5728\u505a\u4e00\u4e2a2D\u6e38\u620f,\u4f46\u662fUnity\u4ecd\u65e7\u4f7f\u7528\u7684\u662f3D\u5750\u6807\u7cfb,\u56e0\u6b64\u8981\u6539\u53d8\u5bf9\u8c61\u4f4d\u7f6e\u7684Vector3.\u867d\u7136\u8fd9\u91cc\u50f5\u5c38\u4e0d\u4f1a\u6539\u53d8z\u8f74\u7684\u4f4d\u7f6e,\u6211\u4eec\u53ef\u4ee5\u7528Vector2\u7c7b\u578b,\u4f46\u662f\u6211\u907f\u514d\u540e\u9762\u8981\u5728Vector2\u548cVector3\u4e24\u79cd\u7c7b\u578b\u8f6c\u6362\u7684\u9ebb\u70e6,\u6211\u8fd8\u662f\u7528Vector3\u4e86.<\/p>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u4ee5\u4fbf\u6709\u8f93\u5165\u65f6\u95f4\u65f6\u66f4\u65b0moveDirection:<\/p>\n<p><code>\/\/ 1<br \/>\nVector3 currentPosition = transform.position;<br \/>\n\/\/ 2<br \/>\nif( Input.GetButton(\"Fire1\") ) {<br \/>\n\/\/ 3<br \/>\nVector3 moveToward = Camera.main.ScreenToWorldPoint( Input.mousePosition );<br \/>\n\/\/ 4<br \/>\nmoveDirection = moveToward - currentPosition;<br \/>\nmoveDirection.z = 0;<br \/>\nmoveDirection.Normalize();<br \/>\n}<\/code><\/p>\n<p>\u4e0b\u9762\u8bf4\u660e\u4e00\u4e0b\u521a\u624d\u8fd9\u6bb5\u4ee3\u7801\u7684\u7528\u9014:<br \/>\n\u6211\u4eec\u8981\u83b7\u5f97\u50f5\u5c38\u5f53\u524d\u4f4d\u7f6e,\u6240\u4ee5\u5c06\u4f4d\u7f6e\u4ed8\u7ed9\u5c40\u90e8\u53d8\u91cf,\u7136\u540e\u5224\u65ad\u9f20\u6807\u5de6\u952e(Fire1)\u662f\u5426\u88ab\u6309\u4e0b,\u7528\u573a\u666f\u7684main Camera,\u8f6c\u6362\u9f20\u6807\u76ee\u524d\u4f4d\u7f6e\u4e3a\u4e16\u754c\u5750\u6807\u7cfb,\u56e0\u4e3aScreenToWorldPoint\u4e0d\u4f1a\u5f71\u54cd\u5230Z\u8f74\u7684\u503c,\u6240\u4ee5\u8fd9\u91cc\u6211\u4eec\u76f4\u63a5\u7528\u9f20\u6807\u7684\u4f4d\u7f6e\u6765\u53d6\u5f97moveToward,\u8ba1\u7b97\u79fb\u52a8\u7684\u65b9\u5411\u662f\u7528\u76ee\u6807\u4f4d\u7f6e\u51cf\u53bb\u50f5\u5c38\u76ee\u524d\u7684\u4f4d\u7f6e,,\u56e0\u4e3a\u4f60\u4e0d\u60f3\u6539\u53d8\u50f5\u5c38Z\u8f74\u7684\u4f4d\u7f6e,\u6240\u4ee5\u6211\u4eec\u8bbe\u7f6emoveDirection\u7684z\u503c\u4e3a0,\u5e76\u7528Normalize\u5c06moveDirection\u53d8\u4e3a\u957f\u5ea6\u4e3a1\u7684&#8221;\u5355\u4f4d\u957f\u5ea6(unit length)&#8221;.Unit length\u7684\u5411\u91cf\u7528\u8d77\u6765\u662f\u5f88\u65b9\u4fbf\u7684,\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u6807\u91cf\u503c,\u5982moveSpeed\u4e58\u4ee5\u8fd9\u4e2a\u5411\u91cf\u6765\u8ba9\u5411\u91cf\u6307\u5411\u4e00\u4e2a\u65b9\u5411,\u800c\u4fdd\u6301\u957f\u5ea6.\u540e\u9762\u4f1a\u7528\u5230\u8fd9\u4e2a.<\/p>\n<p>\u6ce8:\u7528Input\u6765\u8bbf\u95ee\u8f93\u5165\u6570\u636e\u662f\u6bd4\u8f83\u901a\u7528\u7684\u65b9\u6cd5,\u4e00\u4e2a\u9879\u76ee\u9ed8\u8ba4\u5b9a\u4e49\u4e86\u5404\u79cd\u8f93\u5165\u540d\u79f0,\u6bd4\u5982Horizontal, Vertical, \u548c Jump, Horizontal\u662f\u68c0\u6d4b\u64cd\u7eb5\u6746x\u8f74\u7684\u4f4d\u7f6e\u4ee5\u53ca\u952e\u76d8\u5de6\u53f3\u7bad\u5934\u6309\u94ae\u72b6\u6001.\u5982\u679c\u4f60\u9700\u8981\u83b7\u5f97\u6c34\u5e73\u65b9\u5411\u7684\u8f93\u5165\u6570\u636e,\u53ef\u4ee5\u76f4\u63a5\u7528Horizontal\u6765\u83b7\u53d6,\u800c\u4e0d\u7528\u5173\u5fc3\u5177\u4f53\u662f\u600e\u4e48\u83b7\u53d6\u6765\u7684.<\/p>\n<p>Fire1\u9ed8\u8ba4\u5b9a\u4e49\u7684\u662f\u865a\u62df\u952e\u4e4b\u4e00,\u5b83\u6ce8\u518c\u7684\u662f\u4e00\u4e2a\u64cd\u7eb5\u6746\u6216\u9f20\u6807\u7684\u6309\u94ae0,\u800c\u5de6control\u952e\u662f\u7528Input.GetButton\u8fd4\u56de\u7684\u5e03\u5c14\u503c\u83b7\u5f97\u7684.\u4ee3\u7801\u5c06\u5728\u9f20\u6807\u6309\u4e0b\u7684\u6bcf\u4e00\u5e27\u65f6\u66f4\u65b0moveDirection(\u4e0d\u53ea\u662f\u5f53\u521d\u6309\u4e0b\u7684\u90a3\u4e00\u9635).\u6ca1\u9519,\u8fd9\u4e5f\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u901a\u8fc7\u952e\u76d8\u7684\u5de6CTRL\u952e\u6765\u63a7\u5236\u50f5\u5c38\u65b9\u5411,\u53ea\u662f\u8fd8\u8981\u7528\u9f20\u6807\u6765\u638c\u8235.<br \/>\n\u5728Edit\\Project Settings\\Input\u80fd\u770b\u5230\u5173\u4e8eInputManager\u8bbe\u7f6e.<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u6dfb\u52a0\u4e0b\u9762\u7684\u4ee3\u7801\u6765\u505a\u50f5\u5c38\u8ddf\u968f\u9f20\u6807\u8d70\u8def\u7684\u6548\u679c:<\/p>\n<p><code>Vector3 target = moveDirection * moveSpeed + currentPosition;<br \/>\ntransform.position = Vector3.Lerp( currentPosition, target, Time.deltaTime );<\/code><\/p>\n<p>\u7b2c\u4e00\u884c\u662f\u7528\u6765\u8ba1\u7b97\u4ee5moveSpeed\u901f\u5ea6\u5355\u4f4d\u8ba9\u50f5\u5c38\u4ece\u5f53\u524d\u4f4d\u7f6e\u79fb\u52a8\u5230\u76ee\u6807\u4f4d\u7f6e,\u4e5f\u5c31\u662f\u50f5\u5c38\u5c06\u6309\u7167\u5f53\u524d\u4f4d\u7f6e\u671d\u5411\u9f20\u6807\u76ee\u6807\u4f4d\u7f6e\u65b9\u5411\u79fb\u52a8\u8fc7\u53bb.<br \/>\n\u7b2c\u4e8c\u884c\u4f7f\u7528Vector3.Lerp\u6765\u8ba1\u7b97\u5f53\u524d\u4f4d\u7f6e\u4e0e\u76ee\u6807\u4f4d\u7f6e\u4e4b\u524d\u8def\u5f84\u4e0a\u50f5\u5c38\u7684\u65b0\u4f4d\u7f6e,\u7ebf\u6027\u63d2\u503c(Lerp)\u662f\u4e3a\u53d6\u4e24\u4e2a\u503c\u4e4b\u95f4\u5185\u63d2\u503c\u7684\u6700\u4fbf\u5229\u65b9\u6cd5.Lerp\u7b2c\u4e09\u4e2a\u53c2\u6570\u53d6\u503c\u8303\u56f4\u662f0~1,\u8fd9\u610f\u5473\u77400\u65f6\u5c06\u8fd4\u56de\u4f60\u73b0\u5728\u7684\u4f4d\u7f6e\u70b9,\u503c\u4e3a1\u65f6\u5c06\u8fd4\u56de\u76ee\u6807\u70b9,0.5\u65f6\u5c06\u8fd4\u56de\u5b83\u4eec\u7684\u4e2d\u70b9.\u6211\u4eec\u8fd9\u91cc\u7528Time.deltaTime\u6765\u4f5c\u4e3a\u7b2c\u4e09\u4e2a\u53c2\u6570\u503c,\u56e0\u4e3a\u5b83\u662f\u4e00\u79d2\u949f\u7684\u4e00\u5c0f\u90e8\u5206,\u5f88\u53ef\u80fd\u4f1a\u5c0f\u4e8e1,\u4f1a\u8ba9\u4f60\u5f97\u5230\u6cbf\u7740\u8d77\u70b9\u5230\u7ec8\u70b9\u8def\u5f84\u4e0a\u7684\u4e00\u4e9b\u70b9,\u6b63\u56e0\u4e3aTime.deltaTime\u4efb\u4f55\u65f6\u5019\u90fd\u5c06\u63a5\u8fd1\u4e8e1,\u56e0\u6b64\u4f60\u53ef\u4ee5\u5f97\u5230\u4e00\u4e2a\u4e0d\u9519\u7684\u5e73\u6ed1\u8fd0\u52a8.<\/p>\n<p>\u4fdd\u5b58\u8fd9\u4e2a\u811a\u672c\u5e76\u5207\u6362\u56deUnity.<\/p>\n<p>\u8fd0\u884c\u6e38\u620f,\u70b9\u51fb\u67d0\u4e2a\u5730\u65b9\u8ba9\u50f5\u5c38\u8d70\u8fc7\u53bb,\u56e0\u4e3a\u6ca1\u6709\u8bbe\u5b9aZombieController\u7684moveSpeed,\u6240\u4ee5\u5b83\u8fd8\u4e0d\u4f1a\u8d70\u52a8,\u4e0d\u7528\u505c\u6b62\u6e38\u620f,\u6211\u4eec\u5728Inspector\u9762\u677f\u4e2d\u9009\u62e9zombie\u627e\u5230Zombie Controller\u811a\u672c\u7ec4\u4ef6\u6539\u53d8\u79fb\u52a8\u901f\u5ea6\u4e3a2,\u518d\u6b21\u5728\u6c99\u6ee9\u4e0a\u70b9\u51fb\u9f20\u6807,\u4f60\u4f1a\u770b\u5230\u50f5\u5c38\u8d70\u8fc7\u53bb\u4e86.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1498\" rel=\"attachment wp-att-1498\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1498\" alt=\"zombie_brains\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/zombie_brains.gif\" width=\"260\" height=\"260\" \/><\/a><\/p>\n<p>\u5728Inspector\u66f4\u6539\u79fb\u52a8\u901f\u5ea6\u77e5\u9053\u4f60\u89c9\u5f97\u6ee1\u610f.\u6839\u636e\u4f60\u8c03\u6574\u7684\u79fb\u52a8\u901f\u5ea6,\u4f60\u53ef\u80fd\u8fd8\u9700\u8981\u8c03\u6574Zombie Animator\u811a\u672c\u4e2d\u7684Frames Per Second\u6765\u8ba9\u50f5\u5c38\u52a8\u753b\u4e0e\u884c\u8d70\u901f\u5ea6\u76f8\u5339\u914d.<br \/>\n\u5f53\u4f60\u89c9\u5f97\u6ee1\u610f\u7684\u65f6\u5019\u4f60\u8bb0\u4f4f\u73b0\u5728\u8bbe\u5b9a\u7684\u6570\u503c,\u7136\u540e\u505c\u6b62\u6e38\u620f\u7684\u8fd0\u884c,\u91cd\u65b0\u8bbe\u5b9a\u8fd9\u4e9b\u503c\u597d\u8ba9\u4e0b\u6b21\u8fd0\u884c\u65f6\u79fb\u52a8\u901f\u5ea6\u548c\u52a8\u753b\u662f\u6b63\u786e\u7684.<\/p>\n<p>\u8fd9\u4e2a\u65f6\u5019,\u4f60\u6709\u53ef\u80fd\u53d1\u73b0\u4e0b\u9762\u8fd9\u4e9b\u95ee\u9898:<br \/>\n1.\u5f53\u6e38\u620f\u5f00\u59cb\u8fd0\u884c\u65f6,\u4f60\u4f1a\u53d1\u73b0\u50f5\u5c38\u7684\u817f\u5728\u52a8,\u53ef\u5b83\u786e\u5b9e\u9759\u6b62\u5728\u90a3\u91cc\u7684.<br \/>\n2.\u50f5\u5c38\u6109\u5feb\u7684\u5411\u53f3\u8d70\u51fa\u4e86\u5c4f\u5e55.<br \/>\n3.\u4ed6\u8d70\u8def\u7684\u65f6\u5019\u5e76\u4e0d\u770b\u8def.<\/p>\n<p>\u5728\u770b\u5b8c\u8fd9\u4e2a\u6559\u7a0b\u65f6\u4f60\u4f1a\u89e3\u51b3\u5b83\u8dd1\u51fa\u5c4f\u5e55\u7684\u95ee\u9898,\u6240\u4ee5\u73b0\u5728\u6682\u65f6\u5ffd\u7565\u8fd9\u4e2a\u95ee\u9898.\u6b64\u5916,\u5982\u679c\u5b83\u8dd1\u5230\u4e86\u5c4f\u5e55\u5916\u9762,\u53ea\u9700\u518d\u6b21\u70b9\u51fb\u6c99\u6ee9,\u4ed6\u6709\u53ef\u80fd\u5c31\u4f1a\u56de\u6765\u7684.<\/p>\n<p>\u518d\u6b21\u56de\u5230MonoDevelop\u6253\u5f00ZombieController.cs.<br \/>\n\u8fd9\u4e2a\u811a\u672c\u7528moveDirection\u6765\u79fb\u52a8\u50f5\u5c38,\u4f46\u662f\u53ea\u6709\u5f53\u6709\u8f93\u5165\u4e8b\u4ef6\u7684\u65f6\u5019\u5b83\u624d\u5f00\u59cb\u79fb\u52a8,\u4e3a\u4e86\u8ba9\u573a\u666f\u5f00\u59cb\u7684\u65f6\u5019\u5b83\u5c31\u524d\u8fdb,\u6211\u4eec\u9700\u8981\u521d\u59cbmoveDirection\u6307\u5411\u5b83\u7684\u53f3\u65b9.<br \/>\n\u5728Start\u4e2d\u6dfb\u52a0\u4e0b\u9762\u8fd9\u884c:<\/p>\n<p><code>moveDirection = Vector3.right;<\/code><\/p>\n<p>\u8fd9\u4e2a\u70b9\u662f\u5728x\u8f74\u7684\u6b63\u65b9\u5411\u4e0a,\u6362\u53e5\u8bdd\u8bf4\u5b83\u6307\u5411\u671d\u53f3\u7684\u65b9\u5411.<\/p>\n<p>\u4fdd\u5b58ZombieController.cs\u5e76\u56de\u5230Unity\u4e2d\u518d\u6b21\u64ad\u653e\u6e38\u620f.<br \/>\n\u73b0\u5728\u50f5\u5c38\u81ea\u5df1\u5c31\u8dd1\u4e86,\u63a5\u4e0b\u6765\u6211\u4eec\u8981\u8ba9\u4ed6\u770b\u8def\u8d70.<br \/>\n\u56de\u5230ZombieController.cs,\u6dfb\u52a0\u4e00\u4e2a\u516c\u5171\u53d8\u91cf\u5728ZombieController\u4e2d\u505a\u4e3a\u50f5\u5c38\u7684\u626d\u7387:<\/p>\n<p><code>public float turnSpeed;<\/code><\/p>\n<p>\u6211\u4eec\u5c06\u7528turnSpeed\u6765\u63a7\u5236\u50f5\u5c38\u5b9a\u4f4d\u81ea\u5df1\u65b9\u5411\u7684\u54cd\u5e94\u901f\u5ea6.<br \/>\nUnity\u5185\u90e8\u662f\u4f7f\u7528\u56db\u5143\u6570\u8868\u793a\u65cb\u8f6c.\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u56db\u5143\u6570,\u53ef\u4ee5\u770b\u6b64\u94fe\u63a5:http:\/\/en.wikipedia.org\/wiki\/Quaternion,\u4e0d\u8fc7\u4e5f\u8bb8\u4f60\u770b\u4e86\u540e\u4f1a\u89c9\u5f97\u5934\u8111\u53d1\u660f,\u4f46\u503c\u5f97\u5bbd\u6170\u7684\u662f\u5728Unity\u505a2D\u6e38\u620f\u4e0d\u7528\u5b8c\u5168\u4e86\u89e3\u56db\u5143\u6570\u662f\u4ec0\u4e48.<br \/>\n\u56e0\u4e3a\u7528 Quaternion.Euler \u65b9\u6cd5\u53ef\u4ee5\u4ece\u4e00\u4e2a\u6b27\u62c9\u89d2\u83b7\u5f97\u56db\u5143\u6570.\u5927\u591a\u6570\u4eba\u90fd\u4e60\u60ef\u6b27\u62c9\u89d2,\u5b83\u5305\u542b\u5355\u72ec\u7684x,y,z\u7684\u65cb\u8f6c\u89d2\u5ea6.\u867d\u7136\u5b83\u4eec\u56e0\u4e3a\u5982\u4e07\u5411\u8f74\u6b7b\u9501(gimbal lock)\u7b49\u95ee\u9898\u57283D\u521b\u4f5c\u4e2d\u4f7f\u7528\u4e0d\u592a\u7406\u60f3,\u4f46\u5bf9\u4e8e2D\u6e38\u620f\u6765\u8bf4,\u6b27\u62c9\u89d2\u662f\u86ee\u597d\u7528\u7684,\u6211\u4eec\u53ef\u80fd\u53ea\u9700\u8981\u7ed5z\u8f74\u65cb\u8f6c.<\/p>\n<p>\u6ce8:\u6b32\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u56db\u5143\u6570,\u53ef\u4ee5\u770b\u6211\u4eec\u8fd9\u4e2a\u6559\u7a0bOpenGL ES Transformations with Gestures(http:\/\/www.raywenderlich.com\/50398\/opengl-es-transformations-gestures)\u201d.<\/p>\n<p>\u6700\u540e\u6211\u4eec\u5728Update\u811a\u672c\u91cc\u6dfb\u52a0\u4e0b\u9762\u7684\u4ee3\u7801:<\/p>\n<p><code>float targetAngle = Mathf.Atan2(moveDirection.y, moveDirection.x) * Mathf.Rad2Deg;<br \/>\ntransform.rotation =<br \/>\nQuaternion.Slerp( transform.rotation,<br \/>\nQuaternion.Euler( 0, 0, targetAngle ),<br \/>\nturnSpeed * Time.deltaTime );<\/code><\/p>\n<p>\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8fd9\u4e2a\u4ee3\u7801,\u9996\u5148\u6211\u4eec\u7528Mathf.Atan2\u6765\u627e\u5230x\u8f74\u4e0emoveDirection\u4e4b\u95f4\u7684\u89d2\u5ea6.Mathf.Atan2\u5c06\u8fd4\u56de\u89d2\u5ea6\u7684\u5f27\u5ea6,\u6240\u4ee5\u8981\u4e58\u4ee5Mathf.Rad2Deg\u6765\u8f6c\u6362\u4e3a\u89d2\u5ea6.<br \/>\n\u7136\u540e\u7528Quaternion.Slerp\u6765\u8f6c\u5411\u60a8\u6240\u8ba1\u7b97\u7684\u76ee\u6807\u89d2\u5ea6.<br \/>\nQuaternion.Slerp\u6267\u884c\u7684\u662f\u6307\u5b9a\u4e24\u4e2a\u89d2\u5ea6\u7684\u7403\u9762\u7ebf\u6027\u63d2\u503c.\u7c7b\u4f3c\u4e8e\u524d\u9762\u6211\u4eec\u7528\u5230\u7684Vector3.Lerp,\u53ea\u662f\u5b83\u662f\u8ba1\u7b97\u65b0\u7684\u65cb\u8f6c,\u800c\u4e0d\u662f\u8ba1\u7b97\u65b0\u7684\u4f4d\u7f6e.<\/p>\n<p>\u6b64\u524d,\u8c03\u7528Vector3.Lerp,\u5e76\u7528moveSpeed\u8c03\u6574\u50f5\u5c38\u79fb\u52a8\u7684\u8ddd\u79bb,\u540c\u65f6\u7528turnSpeed\u505a\u50f5\u5c38\u7684\u9762\u5411\u89d2\u5ea6\u5904\u7406.<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fZombieController.cs\u811a\u672c,\u4fdd\u5b58\u5b83\u5e76\u56de\u5230Unity.<br \/>\n\u5728Hierarchy\u89c6\u56fe\u9009\u62e9zombie.\u8bbe\u5b9aTurn Speed\u52305,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1495\" rel=\"attachment wp-att-1495\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1495\" alt=\"turn_speed_set\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/turn_speed_set.png\" width=\"274\" height=\"74\" \/><\/a><\/p>\n<p>\u8fd0\u884c\u6e38\u620f\u5e76\u70b9\u51fb\u5468\u56f4\u7684\u6d77\u6ee9,\u50f5\u5c38\u5c06\u59cb\u7ec8\u671d\u5411\u4f60\u9f20\u6807\u70b9\u51fb\u7684\u4f4d\u7f6e.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1443\" rel=\"attachment wp-att-1443\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1443\" alt=\"dizzy_zombie\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/dizzy_zombie.gif\" width=\"250\" height=\"250\" \/><\/a><\/p>\n<p>\u4e0a\u9762\u8fd9\u4e9b\u5c31\u662f\u8fd9\u4e2a\u6559\u7a0b\u6559\u4f60\u505aZombie Conga\u6e38\u620f\u7684\u6240\u6709\u5185\u5bb9.\u901a\u8fc7\u201dFile\\Save Scene as\u2026. \u201d\u5e76\u547d\u540d\u4e3a\u201dCongaScene\u201d\u4fdd\u5b58\u573a\u666f.<\/p>\n<p>\u4e0b\u4e00\u8282\u6211\u4eec\u8981\u8bb2\u4e00\u4e9b\u53ea\u5728Unity\u4e13\u4e1a\u7248(\u4ed8\u8d39\u7248\u672c)\u624d\u63d0\u4f9b\u7684\u529f\u80fd,\u8fd9\u4e9b\u5bf9\u4e8eZombie Conga\u6e38\u620f\u4e0d\u662f\u5fc5\u8981\u7684,\u4f46\u4f60\u53ef\u80fd\u60f3\u4e86\u89e3\u66f4\u590d\u6742\u9879\u76ee\u7684\u5236\u4f5c,\u5c31\u9700\u8981\u7528\u5230\u5b83-Sprite Packing.<\/p>\n<p><strong>\u7cbe\u7075\u5c01\u88c5(Sprite Packing)-\u4ec5\u9488\u5bf9\u4e13\u4e1a\u4eba\u5458.<\/strong><\/p>\n<p>\u6ce8:\u672c\u8282\u4ecb\u7ecd\u7684\u529f\u80fd,\u53ea\u9002\u7528\u4e8eUnity Pro\u4e2d.\u4f60\u4ecd\u7136\u53ef\u4ee5\u5728Unity free\u7248\u672c\u4e2d\u76f4\u63a5\u4f7f\u7528\u4e00\u4e2a\u7eb9\u7406\u56fe\u96c6,\u53ef\u5b83\u9700\u8981\u4f60\u7528\u4e0d\u540c\u7684\u5de5\u5177\u6765\u521b\u5efa\u751f\u6210\u7eb9\u7406\u56fe\u96c6\u7684\u56fe\u7247\u6587\u4ef6.\u4f60\u540c\u6837\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u5c06\u4e00\u4e9b\u7cbe\u7075\u538b\u7f29\u4e3a\u56fe\u96c6\u5207\u7247,\u4f46\u662f\u5b83\u4f1a\u4ee4\u4f60\u7ec4\u7ec7\u548c\u4f7f\u7528\u8d44\u6e90\u53d8\u6210\u5f88\u4e0d\u76f4\u89c2\u7684,\u56e0\u6b64\u6211\u4eec\u8fd9\u91cc\u4e0d\u4ecb\u7ecd\u8fd9\u79cd\u65b9\u6cd5.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1452\" rel=\"attachment wp-att-1452\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1452\" alt=\"game_view_stats_button\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/game_view_stats_button-300x15.png\" width=\"300\" height=\"15\" srcset=\"\/wp-content\/uploads\/2014\/02\/game_view_stats_button-300x15.png 300w, \/wp-content\/uploads\/2014\/02\/game_view_stats_button.png 686w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u64ad\u653e\u6e38\u620f,\u5e76\u70b9\u51fb\u6e38\u620f\u89c6\u56fe\u9876\u90e8\u63a7\u5236\u680f\u7684Stats\u6309\u94ae\u67e5\u770b\u6e32\u67d3\u72b6\u6001\u4fe1\u606f,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1492\" rel=\"attachment wp-att-1492\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1492\" alt=\"stats_no_batching\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/stats_no_batching-300x203.png\" width=\"300\" height=\"203\" srcset=\"\/wp-content\/uploads\/2014\/02\/stats_no_batching-300x203.png 300w, \/wp-content\/uploads\/2014\/02\/stats_no_batching.png 380w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u8bf7\u6ce8\u610f,\u73b0\u5728\u573a\u666f\u4e2d\u56e0\u4e3a\u6ca1\u6709\u8fdb\u884c\u914d\u6599(batching)\u4f18\u5316,\u6240\u4ee5Draw calls\u770b\u8d77\u6765\u5f88\u591a.<\/p>\n<p>\u5f53\u7136,Draw calls\u73b0\u5728\u662f\u6b63\u5e38\u7684,\u56e0\u4e3a\u73b0\u5728\u573a\u666f\u91cc\u6e32\u67d3\u4e86\u56db\u4e2a\u7cbe\u7075,\u6bcf\u4e00\u4e2a\u7cbe\u7075\u90fd\u7528\u4e86\u4e00\u4e2a\u72ec\u81ea\u7684\u6750\u8d28\u7403.\u867d\u7136\u73b0\u5728\u53ea\u6709\u56db\u4e2adraw calls,\u4f46\u771f\u6b63\u7684\u6e38\u620f\u4e2d\u968f\u7740\u573a\u666f\u4e2d\u5bf9\u8c61\u548c\u6548\u679c\u7684\u589e\u52a0,\u8fd9\u4e2adraw calls\u6570\u4e5f\u4f1a\u589e\u52a0,\u592a\u591a\u7684draw calls\u4f1a\u964d\u4f4e\u6e38\u620f\u6027\u80fd,\u6240\u4ee5\u6211\u4eec\u8981\u4ed4\u7ec6\u7684\u7ec4\u7ec7\u7cbe\u7075\u7eb9\u7406,\u5e78\u8fd0\u7684\u662f\u6709\u4e2a\u57fa\u672c\u7684\u65b9\u6cd5\u6765\u5e2e\u52a9\u6211\u4eec\u4f18\u5316draw calls,\u5c31\u662f\u5c06\u96f6\u6563\u7684\u7cbe\u7075\u56fe\u7247\u8f6c\u6362\u6210\u7cbe\u7075\u7eb9\u7406\u56fe\u96c6.\u7eb9\u7406\u56fe\u96c6(texture atlases)\u662f\u7531\u82e5\u5e72\u4e2a\u5c0f\u7eb9\u7406\u7ec4\u6210\u7684\u5927\u7eb9\u7406\u8d34\u56fe,\u7528\u4e8e\u4f18\u5316\u6e32\u67d3\u65f6GPU\u7684\u8c03\u7528,\u8fd9\u4e0d\u662f\u65b0\u6280\u672f,\u4ee5\u524d\u8981\u6211\u4eec\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\u6216\u8005\u624b\u5de5\u521b\u5efa\u5b83,\u800c\u73b0\u5728Unity\u53ef\u4ee5\u5e2e\u6211\u4eec\u81ea\u52a8\u521b\u5efa\u5b83.<\/p>\n<p>\u6ce8:\u5728Unity4.3.2\u7248\u4e2d\u7684Sprite Packing\u4ecd\u5904\u4e8e\u5f00\u53d1\u8005\u9884\u89c8\u6a21\u5f0f.<\/p>\n<p>\u4e3a\u4e86\u5c06\u7cbe\u7075\u5408\u5e76\u5230\u56fe\u96c6\u91cc,\u9996\u5148\u9700\u8981\u4fee\u6539\u5176\u5bfc\u5165\u8bbe\u7f6e.<br \/>\n\u5728Project\u89c6\u56fe\u4e2d\u627e\u5230cat.png\u5e76\u6253\u5f00Import Settings,\u8fd9\u91cc\u6ce8\u610f\u540d\u4e3aPacking\u7684\u6807\u7b7e\u5c5e\u6027. Packing\u6807\u7b7e\u7528\u6765\u5b9a\u4e49\u7cbe\u7075\u52a0\u5165\u5230\u7eb9\u7406\u56fe\u96c6\u540e\u7684\u540d\u79f0,\u53ef\u4ee5\u662f\u4efb\u4f55\u4f60\u60f3\u8981\u7684\u5b57\u7b26\u4e32.<br \/>\n\u5728Packing\u6807\u7b7e\u4e2d\u8f93\u5165\u5b83\u7684\u540d\u5b57&#8221;toons&#8221;:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1464\" rel=\"attachment wp-att-1464\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1464\" alt=\"packing_tag_set\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/packing_tag_set.png\" width=\"274\" height=\"160\" \/><\/a><\/p>\n<p>\u7136\u540e\u70b9\u51fb\u5e94\u7528\u6309\u94ae\u4fdd\u5b58\u8bbe\u7f6e,\u7528\u540c\u6837\u7684\u65b9\u6cd5\u5c06enemy\u548czombie\u4e5f\u547d\u540d\u4e00\u4e0b.<br \/>\n\u7136\u540e\u4ece&#8221;Window\\Sprite Packer&#8221;\u83dc\u5355\u4e2d\u6253\u5f00&#8221;Sprite Packer&#8221;,\u5982\u679c\u662f4.3.2\u7248\u672c,\u6709\u53ef\u80fd\u662f&#8221; Window\\Sprite Packer (Developer Preview)&#8221;\u8fd9\u6837\u7684\u83dc\u5355,\u90a3\u4e48\u5c06\u4f1a\u663e\u793a\u4e0b\u9762\u8fd9\u6837\u7684\u9519\u8bef\u63d0\u793a:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1482\" rel=\"attachment wp-att-1482\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1482\" alt=\"sprite_packer_disabled_error\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_packer_disabled_error-300x35.png\" width=\"300\" height=\"35\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_packer_disabled_error-300x35.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_packer_disabled_error.png 502w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u6b63\u5982\u4f60\u6240\u89c1\u9ed8\u8ba4\u662f\u7981\u7528Sprite packing\u7684,\u6211\u4eec\u5230&#8221;Edit\\Project Settings\\Editor&#8221;\u4e2d\u628aSprite Packer\u7684\u6a21\u5f0f\u9009\u4e3a&#8221;Always Enabled&#8221;,\u50cf\u4e0b\u56fe\u8fd9\u6837:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1445\" rel=\"attachment wp-att-1445\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1445\" alt=\"editor_settings_sprite_packer\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/editor_settings_sprite_packer-246x300.png\" width=\"246\" height=\"300\" srcset=\"\/wp-content\/uploads\/2014\/02\/editor_settings_sprite_packer-246x300.png 246w, \/wp-content\/uploads\/2014\/02\/editor_settings_sprite_packer.png 274w\" sizes=\"auto, (max-width: 246px) 100vw, 246px\" \/><\/a><\/p>\n<p>\u5f53\u9009\u62e9&#8221;Always Enabled&#8221;\u540e,\u4f60\u53ef\u4ee5\u5728build\u65f6\u5019\u770b\u5230\u4e00\u4e2a&#8221;only packing your Sprites for builds&#8221;\u9009\u9879.<\/p>\n<p>\u518d\u6b21\u4ece&#8221;Window\\Sprite Packer&#8221;\u83dc\u5355\u6253\u5f00Sprite Packer\u7a97\u53e3,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1483\" rel=\"attachment wp-att-1483\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1483\" alt=\"sprite_packer_empty\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_packer_empty-300x252.png\" width=\"300\" height=\"252\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_packer_empty-300x252.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_packer_empty.png 502w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u9ec4\u8272\u7684\u6587\u5b57\u662f\u63d0\u9192\u4f60\u7528\u7684\u662f\u4e00\u4e2a\u529f\u80fd\u7684\u9884\u89c8\u7248.\u4ee5\u540e\u6b63\u5f0f\u7248\u5c31\u4e0d\u4f1a\u770b\u5230\u8fd9\u4e2a\u63d0\u9192\u6587\u5b57\u4e86.<\/p>\n<p>\u5728\u8fd9\u4e2a\u7a97\u53e3\u7684\u5de6\u4e0a\u65b9\u70b9\u51fbPack\u6309\u94ae,\u4f60\u4f1a\u770b\u5230\u7cbe\u7075\u90fd\u6392\u5217\u5728\u7a97\u53e3\u91cc\u4e86,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1484\" rel=\"attachment wp-att-1484\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1484\" alt=\"sprite_packer_toons_atlas\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_packer_toons_atlas-300x252.png\" width=\"300\" height=\"252\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_packer_toons_atlas-300x252.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_packer_toons_atlas.png 502w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u518d\u6b21\u8fd0\u884c\u6e38\u620f\u5230\u6e38\u620f\u89c6\u56fe\u67e5\u770b\u8fd0\u884c\u72b6\u6001\u4fe1\u606f,\u4f60\u5c06\u770b\u5230\u73b0\u5728\u53ea\u7528\u4e86\u4e24\u4e2adraw calls,\u6bd4\u539f\u6765\u7701\u4e86\u4e24\u4e2a.<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1493\" rel=\"attachment wp-att-1493\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1493\" alt=\"stats_with_batching\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/stats_with_batching-300x206.png\" width=\"300\" height=\"206\" srcset=\"\/wp-content\/uploads\/2014\/02\/stats_with_batching-300x206.png 300w, \/wp-content\/uploads\/2014\/02\/stats_with_batching.png 396w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u663e\u800c\u6613\u89c1\u7684,\u7cbe\u7075\u5171\u4eab\u4f7f\u7528\u4e86\u6750\u8d28\u7403,\u4f18\u5316\u4e86\u6027\u80fd,\u540c\u65f6\u505a\u8fd9\u4e2a\u4f18\u5316\u5982\u6b64\u7b80\u5355,\u4f55\u4e50\u4e0d\u4e3a.<\/p>\n<p><strong>Sprite Packer\u7684\u9009\u9879\u548c\u95ee\u9898<\/strong><\/p>\n<p>Sprite Packer\u7a97\u53e3\u9876\u90e8\u5305\u542b\u4e00\u4e2a\u63a7\u5236\u680f,\u5982\u4e0b\u56fe:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1481\" rel=\"attachment wp-att-1481\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1481\" alt=\"sprite_packer_ctrl_bar\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_packer_ctrl_bar-300x22.png\" width=\"300\" height=\"22\" srcset=\"\/wp-content\/uploads\/2014\/02\/sprite_packer_ctrl_bar-300x22.png 300w, \/wp-content\/uploads\/2014\/02\/sprite_packer_ctrl_bar.png 502w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>1:\u89c6\u56fe\u4e2d\u770b\u5230\u7684\u662f\u76ee\u524d\u7684\u56fe\u96c6.\u7b2c\u4e00\u4e2a\u4e0b\u62c9\u83dc\u5355\u662f\u4f60\u4f7f\u7528\u8fc7\u7684Packing\u6807\u7b7e\u540d\u79f0.\u53ef\u4ee5\u9009\u62e9\u5b83\u67e5\u770b\u5b83\u7684\u5185\u5bb9.<br \/>\n2:\u5982\u679cSprite Packer\u5e2e\u4f60\u6574\u5408\u56fe\u96c6\u8d85\u8fc7\u4e00\u5f20\u56fe,\u4f60\u9700\u8981\u901a\u8fc7\u7b2c\u4e8c\u4e2a\u4e0b\u62c9\u83dc\u5355\u5207\u6362\u5176\u5b83\u56fe\u96c6.<br \/>\n3:\u9ed8\u8ba4\u7cbe\u7075\u5728\u56fe\u96c6\u4e2d\u7684\u5206\u914d\u65b9\u6cd5\u662f\u6309\u7167DefaultPackerPolicy\u8fdb\u884c\u7684,\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574DefaultPackerPolicy\u6765\u81ea\u5b9a\u4e49\u5206\u914d\u65b9\u6cd5,\u4e0d\u8fc7\u8fd9\u4e2a\u9ad8\u7ea7\u529f\u80fd\u672c\u6559\u7a0b\u5c31\u4e0d\u4ecb\u7ecd\u4e86.<\/p>\n<p>\u6709\u65f6\u5019Unity\u4f1a\u5c06\u6211\u4eec\u672c\u6765\u8981\u6574\u5408\u5230\u4e00\u4e2a\u56fe\u96c6\u62c6\u5206\u521b\u5efa\u6210\u591a\u4e2a\u5730\u56fe\u96c6,\u5e76\u628a\u540d\u5b57\u52a0\u4e86\u5e8f\u53f7.\u9020\u6210\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u662f\u7cbe\u7075\u7eb9\u7406\u538b\u7f29\u683c\u5f0f\u4e0d\u540c.<\/p>\n<p>\u4f8b\u5982:zombie.png\u6211\u4eec\u8bbe\u7f6e\u7684\u662f16\u4f4d\u989c\u8272(16 bits),\u800cenemy.png\u548ccat.png\u662f\u7528\u7684\u538b\u7f29\u683c\u5f0f(Compressed),\u90a3\u4e48Unity\u6574\u5408\u56fe\u96c6\u65f6,\u5c06\u4f1a\u521b\u5efa\u51fa\u4e24\u4e2a\u56fe\u96c6,\u540d\u79f0\u5206\u522b\u662f&#8221;toons (Group 1)&#8221;\u548c&#8221;toons (Group 2)&#8221;:<\/p>\n<p><a href=\"http:\/\/blog.1vr.cn\/?attachment_id=1480\" rel=\"attachment wp-att-1480\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1480\" alt=\"sprite_packer_atlas_groups\" src=\"http:\/\/blog.1vr.cn\/wp-content\/uploads\/2014\/02\/sprite_packer_atlas_groups-300x251.gif\" width=\"300\" height=\"251\" \/><\/a><\/p>\n<p>\u5c3d\u7ba1\u8fd9\u4e09\u4e2a\u7cbe\u7075\u6709\u76f8\u540c\u7684Packing\u6807\u7b7e,\u4f46Unity\u4ecd\u65e7\u521b\u5efa\u4e86\u591a\u4e2a\u56fe\u96c6.\u4e3a\u4e86\u786e\u4fdd\u56fe\u96c6\u6700\u4f18\u5316,\u6211\u4eec\u8981\u786e\u4fdd\u51c6\u5907\u6574\u5408\u5230\u540c\u4e00\u4e2a\u56fe\u96c6\u4e2d\u7684\u7cbe\u7075\u7684\u538b\u7f29\u683c\u5f0f\u76f8\u540c.<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b,\u5c06\u5c3d\u53ef\u80fd\u7684\u51cf\u5c11\u7cbe\u7075\u56fe\u96c6\u7684\u603b\u6570,\u9664\u975e\u7cbe\u7075\u592a\u591a,\u4e00\u5f20\u56fe\u96c6\u5b58\u4e0d\u4e0b,Unity\u4f1a\u518d\u6b21\u81ea\u52a8\u62c6\u5206\u56fe\u96c6,\u6211\u4eec\u8981\u7528Packing\u6807\u7b7e\u5408\u7406\u5b89\u6392\u7cbe\u7075\u5f52\u5c5e,\u5c3d\u53ef\u80fd\u505a\u5230\u7cbe\u7075\u56fe\u96c6\u7684\u6700\u4f18\u5316.<\/p>\n<p>\u597d\u4e86,\u672c\u6559\u7a0b\u5230\u6b64\u7ed3\u675f,\u53ef\u4ee5\u4ece\u8fd9\u91cc\u4e0b\u8f7d\u5230\u5b8c\u6210\u7684\u9879\u76ee\u6e90\u7801:(<a href=\"http:\/\/cdn5.raywenderlich.com\/wp-content\/uploads\/2014\/01\/ZombieConga-Part1-complete.zip\">http:\/\/cdn5.raywenderlich.com\/wp-content\/uploads\/2014\/01\/ZombieConga-Part1-complete.zip<\/a>),\u5b98\u65b9\u51fa\u7684\u4e2d\u6587\u5b57\u5e55\u72482D\u5de5\u5177\u89c6\u9891\u6559\u7a0b:<a href=\"http:\/\/v.youku.com\/v_show\/id_XNjQxNDk0MTg4.html\">http:\/\/v.youku.com\/v_show\/id_XNjQxNDk0MTg4.html<\/a><\/p>\n<p><strong>\u539f\u6587:<a href=\"http:\/\/www.raywenderlich.com\/61532\/unity-2d-tutorial-getting-started\">http:\/\/www.raywenderlich.com\/61532\/unity-2d-tutorial-getting-started<\/a>,\u4f5c\u8005:<strong>Christopher LaPollo<\/strong>,\u7531<strong>Xiaoke<\/strong>\u7ffb\u8bd1,\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u6765\u81eahttp:\/\/www.1vr.cn<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5199\u5728\u524d\u9762\u7684\u8bdd:\u8f6c\u8f7d\u80af\u5b9a\u4f1a\u7559\u539f\u6587\u94fe\u63a5,\u4f5c\u8005\u7684\u7f72\u540d,\u8fd9\u662f\u6bcb\u5eb8\u7f6e\u7591\u7684.\u800c\u6211\u7684\u4e60\u60ef\u662f\u7ffb\u8bd1\u5b8c\u6587\u5b57\u540e\u4f1a\u901a\u77e5\u5230\u539f\u4f5c\u8005\u5e76\u5206\u4eab\u7ed9 &hellip; <a href=\"https:\/\/1vr.cn\/?p=1422\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Unity 2D\u5165\u95e8\u57fa\u7840\u6559\u7a0b<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1422","post","type-post","status-publish","format-standard","hentry","category-5","without-featured-image"],"_links":{"self":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1422"}],"version-history":[{"count":6,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1422\/revisions"}],"predecessor-version":[{"id":1515,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/1422\/revisions\/1515"}],"wp:attachment":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}