{"id":286235,"date":"2017-05-12T15:05:02","date_gmt":"2017-05-12T11:05:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286235"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286235","title":{"rendered":"Unity3D. \u0411\u0430\u043b\u0443\u0435\u043c\u0441\u044f \u0441 \u043c\u0435\u0448\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442"},"content":{"rendered":"<p>\u0414\u0430\u0432\u043d\u044b\u043c \u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 Unity3D. \u042d\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u0438, \u043d\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0438 \u0442\u0451\u043f\u043b\u044b\u0435, \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u043e\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u043d\u044f\u0445 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043e\u0442 \u0441\u0442\u0430\u0440\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <code>assetpackage PlanetWalker<\/code>. \u042d\u0442\u043e \u0431\u044b\u043b \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u0433\u0440\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u0441\u043c\u043e\u0441\u0443 \u0438 \u043f\u043e\u0441\u0435\u0449\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043b\u0430\u043d\u0435\u0442\u044b, \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043a\u0440\u043e\u043c\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u0438 \u043d\u0435\u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0448\u0430 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u0447\u0435\u0433\u043e. \u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044f \u0442\u043e\u0440\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043b\u044f\u043d\u0443\u0441\u044c, \u0447\u0442\u043e \u0437\u0430\u043c\u044b\u0448\u043b\u044f\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u043b\u043e\u0441\u0442\u044c&#8230;<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/e43\/77b\/092\/e4377b092cea4dc1aa4596f8958288fa.PNG\"\/><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0448\u0435 \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u043c\u0435\u0448. \u041a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0448 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c, \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0435\u0448.<\/p>\n<p>  <\/p>\n<h1>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0435\u0448<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0448 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0438\u0433\u0440\u0430\u0445. \u041d\u043e \u0447\u0442\u043e \u043e\u043d \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442?<\/p>\n<p>  <\/p>\n<p>\u0412 Unity \u043c\u0435\u0448 \u0438\u043c\u0435\u0435\u0442:<\/p>\n<p>  <\/p>\n<ul>\n<li>vertices \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432\u0435\u0440\u0448\u0438\u043d \u043c\u0435\u0448\u0430<\/li>\n<li>triangles \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u044b (\u043f\u0440\u043e\u0449\u0435 \u2014 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438)<\/li>\n<li>normals \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u0433\u043e, \u043a\u0443\u0434\u0430 \u043a\u0430\u0436\u0434\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u0442 (\u043a\u0430\u0436\u0434\u0430\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u043f\u0435\u0440\u043f\u0435\u043d\u0434\u0438\u043a\u0443\u043b\u044f\u0440\u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435)<\/li>\n<li>uv \u2014 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b<\/li>\n<li>colors \u2014 \u043c\u0430\u0441\u0441\u0438\u0432 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432\u0435\u0440\u0448\u0438\u043d (\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u043d\u0438\u043c\u0438)<\/li>\n<li>tangents \u2014 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 (\u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432)<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043c\u0435\u0448 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f, \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u0432\u0435\u0442, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u0438 \u0442.\u0434. \u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043d\u0435\u0433\u043e \u0441 \u0442\u0430\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e? \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 Unity \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c 65025 \u0448\u0442\u0443\u043a. \u0420\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0443\u0442\u0451\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u0435\u0448\u0430.<\/p>\n<p>  <\/p>\n<h1>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043a\u0430\u0440\u0442\u0430 \u0432\u044b\u0441\u043e\u0442<\/h1>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/027\/990\/6e8\/0279906e8f6e486db7e61fce87c856ec.jpg\"\/><br \/>  \u0412\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0437 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442. \u041a\u0430\u0440\u0442\u0430 \u0432\u044b\u0441\u043e\u0442 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0447\u0451\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a, \u0433\u0434\u0435 \u0447\u0435\u043c \u0442\u0435\u043c\u043d\u0435\u0435 \u043f\u0438\u043a\u0441\u0435\u043b\u044c, \u0442\u0435\u043c \u043d\u0438\u0436\u0435 \u0432\u044b\u0441\u043e\u0442\u0430, \u0430 \u0447\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0441\u0432\u0435\u0442\u043b\u0435\u0435 \u2014 \u0442\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0430 \u0432\u044b\u0448\u0435. \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e!<\/p>\n<p>  <\/p>\n<h1>\u0422\u0435\u043e\u0440\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u0430\u043c \u043c\u0435\u0448, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u0430\u0440\u0442\u0443 \u0432\u044b\u0441\u043e\u0442? \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0440\u0438\u0441\u0443\u043d\u043e\u043a, \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u044b\u0441\u043e\u0442\u0443 \u0432\u0435\u0440\u0448\u0438\u043d\u044b. \u0412 \u0442\u0435\u043e\u0440\u0438\u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044e \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442 \u0438 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u043e\u043d\u0430, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0432\u043e float \u043e\u0442 0 \u0434\u043e 1 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0435\u0448 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/Texture2D.GetPixel.html\">GetPixel<\/a> \u0438 <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/Color-grayscale.html\">Color.grayscale<\/a>. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0433\u0430\u043b\u043e\u0447\u043a\u0430 <code>Read&amp;Write<\/code>, \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h1>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u044f<\/h1>\n<p>  <\/p>\n<p>\u0421 \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0435\u0448 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c, \u043f\u043e\u0440\u0430 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0440\u0430\u0431\u043e\u0442\u0435. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043a\u043e\u0434, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>ParentEditor<\/code>. \u0412 \u043d\u0435\u0433\u043e \u043c\u044b \u0437\u0430\u0441\u0443\u043d\u0435\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043e\u0442 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u041f\u043e \u0437\u0430\u0434\u0443\u043c\u043a\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u043e\u043a\u043d\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <code>EditorWindow<\/code>.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u0443\u043c\u0430\u044e, \u0442\u0443\u0442 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u043d\u0443\u0436\u043d\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>using UnityEditor; using UnityEngine;  public class ParentEditor : EditorWindow {     public void CreatePaths()     {         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools&quot;)) AssetDatabase.CreateFolder(&quot;Assets&quot;, &quot;MeshTools&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Meshes&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools&quot;, &quot;Meshes&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Meshes\/Generated&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools\/Meshes&quot;, &quot;Generated&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Meshes\/Updated&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools\/Meshes&quot;, &quot;Updated&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Prefabs&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools&quot;, &quot;Prefabs&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Prefabs\/Generated&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools\/Prefabs&quot;, &quot;Generated&quot;);         if (!AssetDatabase.IsValidFolder(&quot;Assets\/MeshTools\/Prefabs\/Updated&quot;)) AssetDatabase.CreateFolder(&quot;Assets\/MeshTools\/Prefabs&quot;, &quot;Updated&quot;);     }      public int Cut(int value)     {         return Mathf.Min(value, 255);     }      public Mesh CopyMesh(Mesh mesh)     {         Mesh newmesh = new Mesh();         newmesh.vertices = mesh.vertices;         newmesh.triangles = mesh.triangles;         newmesh.uv = mesh.uv;         newmesh.normals = mesh.normals;         newmesh.tangents = mesh.tangents;         return newmesh;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443&#8230;<\/p>\n<p>  <\/p>\n<h1>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043c\u0435\u0448\u0430<\/h1>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>MeshGenerator<\/code> \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u0442 <code>ParentEditor<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0432 \u043d\u0451\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0445 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0438\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u043c\u0438 \u0438 \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">MeshGenerator<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>using UnityEditor; using UnityEngine;  public class MeshGenerator : ParentEditor {     public Texture2D heightMap;     public Material mat;     public Vector3 size = new Vector3(2048, 300, 2048);     public string mname = &quot;Enter name&quot;;     GameObject generated;     [MenuItem(&quot;Tools\/Mesh Generator&quot;)]     static void Init()     {         MeshGenerator mg = (MeshGenerator)GetWindow(typeof(MeshGenerator));         mg.Show();     }       void OnGUI()     {         heightMap = (Texture2D)EditorGUILayout.ObjectField(&quot;Height map&quot;, heightMap, typeof(Texture2D), false);         mat = (Material)EditorGUILayout.ObjectField(&quot;Material&quot;, mat, typeof(Material), false);         size = EditorGUILayout.Vector3Field(&quot;Size&quot;, size);         mname = EditorGUILayout.TextField(&quot;Name&quot;, mname); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043c \u043c\u0435\u0448 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 GO<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Generate<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>    GameObject Generate()     {         \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c GO \u0438 \u0432\u0435\u0448\u0430\u0435\u043c \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e         GameObject go = new GameObject(mname);         go.transform.position = Vector3.zero;         go.AddComponent&lt;MeshFilter&gt;();         go.AddComponent&lt;MeshRenderer&gt;();          \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 - \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435         if (mat != null) go.GetComponent&lt;Renderer&gt;().material = mat;         else         {             Debug.LogError(&quot;No material attached! Aborting&quot;);             return null;         }          \/\/ \u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043f\u0440\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 Unity \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443         \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442 \u0438 255         \/\/ 255*255 = 65025         int width = Cut(heightMap.width);         int height = Cut(heightMap.height);          \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0435\u0448         Mesh mesh = new Mesh();          Vector3[] vertices = new Vector3[height * width]; \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u0440\u0448\u0438\u043d         Vector2[] UVs = new Vector2[height * width]; \/\/ uv \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442         Vector4[] tangs = new Vector4[height * width]; \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445          \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c         Vector2 uvScale = new Vector2(1 \/ (width - 1), 1 \/ (height - 1));         Vector3 sizeScale = new Vector3(size.x \/ (width - 1), size.y, size.z \/ (height - 1));                                            \/\/ \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0443 \u043d\u0430\u0441 Vector2 (x, y)                                          \/\/ \u043d\u043e \u043c\u0435\u0448 \u0443 \u043d\u0430\u0441 Vector3(x, y, z). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0441\u043e\u0442\u0430                                         \/\/ \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 z \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443          int index;         float pixelHeight;         for (int y = 0; y &lt; height; y++) {             for (int x = 0; x &lt; width; x++)             {                 index = y * width + x;  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441                  pixelHeight = heightMap.GetPixel(x, y).grayscale; \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u044b\u0441\u043e\u0442\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u043d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0432\u044b\u0441\u043e\u0442                 Vector3 vertex = new Vector3(x, pixelHeight, y); \/\/ \u0437\u0430\u0434\u0430\u0451\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443                 vertices[index] = Vector3.Scale(sizeScale, vertex); \/\/ \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u0438\u043c \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c                 Vector2 cur_uv = new Vector2(x, y); \/\/ \u0437\u0430\u0434\u0430\u0451\u043c uv \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443                 UVs[index] = Vector2.Scale(cur_uv, uvScale); \/\/ \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c uv \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0441\u0438\u043c \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u043c                  \/*                 Vector*.Scale(Vector* a, Vector* b) \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.                 \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Vector3.Scale(a=(1, 2, 1), b=(2, 3, 1)) \u0432\u0435\u0440\u043d\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 (2, 6, 1)                 *\/                  \/* \u0420\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e: \u044d\u0442\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u0434\u0451\u0442 \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b                  \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 X. \u0412\u0435\u043a\u0442\u043e\u0440 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0443\u0436\u0435\u043d \u043d\u0430\u043c \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b                  \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u043a \u043c\u0435\u0448\u0443.                  W \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 \u043b\u0438\u0431\u043e -1, \u043b\u0438\u0431\u043e 1, \u0442\u0430\u043a \u043a\u0430\u043a                  \u0431\u0438\u043d\u043e\u0440\u043c\u0430\u043b\u044c \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0442\u0451\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043d\u0430 W \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 *\/                 Vector3 leftV = new Vector3(x - 1, heightMap.GetPixel(x - 1, y).grayscale, y);                 Vector3 rightV = new Vector3(x + 1, heightMap.GetPixel(x + 1, y).grayscale, y);                 Vector3 tang = Vector3.Scale(sizeScale, rightV - leftV).normalized;                 tangs[index] = new Vector4(tang.x, tang.y, tang.z, 1);             }         }          \/\/ \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0435\u0440\u0432\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043c\u0435\u0448\u0435         mesh.vertices = vertices; \/\/ \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b         mesh.uv = UVs; \/\/ \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c uv \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b          \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0435 \u0441\u0430\u043c\u044b\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438         index = 0;         int[] triangles = new int[(height - 1) * (width - 1) * 6];         for (int y = 0; y &lt; height - 1; y++)         {             for (int x = 0; x &lt; width - 1; x++)             {                 \/\/ \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e\u043b\u0438\u0433\u043e\u043d                 triangles[index++] = (y * width) + x;                 triangles[index++] = ((y + 1) * width) + x;                 triangles[index++] = (y * width) + x + 1;                  triangles[index++] = ((y + 1) * width) + x;                 triangles[index++] = ((y + 1) * width) + x + 1;                 triangles[index++] = (y * width) + x + 1;             }         }         \/\/ \u0414\u0430\u0451\u043c \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439         mesh.triangles = triangles;          \/\/ \u0410\u0432\u0442\u043e\u0440\u0430\u0441\u0447\u0451\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u043c\u0435\u0448\u0435         mesh.RecalculateNormals();          \/\/ \u041a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439         mesh.tangents = tangs;          \/\/ \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u0435\u0448         go.GetComponent&lt;MeshFilter&gt;().sharedMesh = mesh;         return go;     }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u0443\u043f\u0435\u0440! \u0421 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435. \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 <code>OnGUI<\/code> \u043c\u0435\u0442\u043e\u0434, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043e\u0434\u043d\u043e.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u043e\u0432\u044b\u0439 OnGUI<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>    void OnGUI()     {         heightMap = (Texture2D)EditorGUILayout.ObjectField(&quot;Height map&quot;, heightMap, typeof(Texture2D), false);         mat = (Material)EditorGUILayout.ObjectField(&quot;Material&quot;, mat, typeof(Material), false);         size = EditorGUILayout.Vector3Field(&quot;Size&quot;, size);         mname = EditorGUILayout.TextField(&quot;Name&quot;, mname);          if (GUILayout.Button(&quot;Generate mesh&quot;, GUILayout.Height(20))) generated = Generate();          if (GUILayout.Button(&quot;Save&quot;, GUILayout.Height(20)))         {             Mesh generated_mesh = generated.GetComponent&lt;MeshFilter&gt;().sharedMesh;             CreatePaths();             AssetDatabase.CreateAsset(generated_mesh, &quot;Assets\/MeshTools\/Meshes\/Generated\/&quot; + mname + &quot;.asset&quot;); \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043c\u0435\u0448             PrefabUtility.CreatePrefab(&quot;Assets\/MeshTools\/Prefabs\/Generated\/&quot; + mname + &quot;.prefab&quot;, generated); \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043f\u0440\u0435\u0444\u0430\u0431 \u043d\u0430\u0448\u0435\u0433\u043e GO         }     }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0451 \u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0442\u043e \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u043c\u0435\u043d\u044e <code>Tools-&gt;Mesh Generator<\/code> \u0438 \u0432\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0442\u0443\u0434\u0430 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442 \u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b! \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 <code>ParentEditor<\/code>, \u0430 \u0441\u0430\u043c \u0432\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">MeshGenerator.cs<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>using UnityEditor; using UnityEngine;  public class MeshGenerator : ParentEditor {     public Texture2D heightMap;     public Material mat;     public Vector3 size = new Vector3(2048, 300, 2048);     public string mname = &quot;Enter name&quot;;     GameObject generated;     [MenuItem(&quot;Tools\/Mesh Generator&quot;)]     static void Init()     {         MeshGenerator mg = (MeshGenerator)GetWindow(typeof(MeshGenerator));         mg.Show();     }      void OnGUI()     {         heightMap = (Texture2D)EditorGUILayout.ObjectField(&quot;Height map&quot;, heightMap, typeof(Texture2D), false);         mat = (Material)EditorGUILayout.ObjectField(&quot;Material&quot;, mat, typeof(Material), false);         size = EditorGUILayout.Vector3Field(&quot;Size&quot;, size);         mname = EditorGUILayout.TextField(&quot;Name&quot;, mname);          if (GUILayout.Button(&quot;Generate mesh&quot;, GUILayout.Height(20))) generated = Generate();          if (GUILayout.Button(&quot;Save&quot;, GUILayout.Height(20)))         {             Mesh generated_mesh = generated.GetComponent&lt;MeshFilter&gt;().sharedMesh;             CreatePaths();             AssetDatabase.CreateAsset(generated_mesh, &quot;Assets\/MeshTools\/Meshes\/Generated\/&quot; + mname + &quot;.asset&quot;);             PrefabUtility.CreatePrefab(&quot;Assets\/MeshTools\/Prefabs\/Generated\/&quot; + mname + &quot;.prefab&quot;, generated);         }     }      GameObject Generate()     {         GameObject go = new GameObject(mname);         go.transform.position = Vector3.zero;         go.AddComponent&lt;MeshFilter&gt;();         go.AddComponent&lt;MeshRenderer&gt;();          if (mat != null) go.GetComponent&lt;Renderer&gt;().material = mat;         else         {             Debug.LogError(&quot;No material attached! Aborting&quot;);             return null;         }          int width = Cut(heightMap.width);         int height = Cut(heightMap.height);          Mesh mesh = new Mesh();          Vector3[] vertices = new Vector3[height * width];         Vector2[] UVs = new Vector2[height * width];         Vector4[] tangs = new Vector4[height * width];          Vector2 uvScale = new Vector2(1 \/ (width - 1), 1 \/ (height - 1));         Vector3 sizeScale = new Vector3(size.x \/ (width - 1), size.y, size.z \/ (height - 1));          int index;         float pixelHeight;         for (int y = 0; y &lt; height; y++)         {             for (int x = 0; x &lt; width; x++)             {                 index = y * width + x;                  pixelHeight = heightMap.GetPixel(x, y).grayscale;                 Vector3 vertex = new Vector3(x, pixelHeight, y);                 vertices[index] = Vector3.Scale(sizeScale, vertex);                 Vector2 cur_uv = new Vector2(x, y);                 UVs[index] = Vector2.Scale(cur_uv, uvScale);                   Vector3 leftV = new Vector3(x - 1, heightMap.GetPixel(x - 1, y).grayscale, y);                 Vector3 rightV = new Vector3(x + 1, heightMap.GetPixel(x + 1, y).grayscale, y);                 Vector3 tang = Vector3.Scale(sizeScale, rightV - leftV).normalized;                 tangs[index] = new Vector4(tang.x, tang.y, tang.z, 1);             }         }          mesh.vertices = vertices;         mesh.uv = UVs;          index = 0;         int[] triangles = new int[(height - 1) * (width - 1) * 6];         for (int y = 0; y &lt; height - 1; y++)         {             for (int x = 0; x &lt; width - 1; x++)             {                 triangles[index++] = (y * width) + x;                 triangles[index++] = ((y + 1) * width) + x;                 triangles[index++] = (y * width) + x + 1;                  triangles[index++] = ((y + 1) * width) + x;                 triangles[index++] = ((y + 1) * width) + x + 1;                 triangles[index++] = (y * width) + x + 1;             }         }          mesh.triangles = triangles;         mesh.RecalculateNormals();         mesh.tangents = tangs;         go.GetComponent&lt;MeshFilter&gt;().sharedMesh = mesh;         return go;     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u043a\u0430\u0440\u0442\u0443 \u0432\u044b\u0441\u043e\u0442 \u0438 \u0443\u043a\u0430\u0436\u0435\u043c \u0435\u0451 <code>MaxSize<\/code> \u0432 256, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0433\u0430\u043b\u043e\u0447\u043a\u0443 <code>Read&amp;Write<\/code> \u0438 \u043d\u0430\u0436\u043c\u0451\u043c \u043d\u0430 <code>Apply<\/code>.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/100\/11b\/b7d\/10011bb7d5134f86a0645e6efc43d1e4.PNG\"\/><\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u043d\u0430\u0448\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <code>Tools-&gt;Mesh Generator<\/code><br \/>  \u0418 \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u043a\u043d\u043e (\u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u043d\u043e \u0443\u0436\u0435 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438):<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/5cd\/368\/388\/5cd3683883dd4bb981602d8d25392d1d.PNG\"\/><br \/>  \u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 <code>Generate Mesh<\/code> \u0438&#8230;<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/4f5\/b3f\/e75\/4f5b3fe75bec455587499f295b02c989.PNG\"\/><br \/>  <em>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 Shaded and Wireframe<\/em><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/2ac\/8a0\/09a\/2ac8a009acc641b188b5b29c0df6cfce.jpg\"\/><br \/>  <em>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u0432\u044b\u0441\u043e\u0442<\/em><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>Save<\/code> \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0448 \u0438 \u043f\u0440\u0435\u0444\u0430\u0431 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 &quot;Assets\/MeshTools\/Meshes\/Generated&quot; \u0438 &quot;Assets\/MeshTools\/Prefabs\/Generated&quot; \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0428\u0430\u043b\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u0430\u0441\u044c! \ud83d\ude42<\/p>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/328498\/\"> https:\/\/habrahabr.ru\/post\/328498\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0430\u0432\u043d\u044b\u043c \u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 Unity3D. \u042d\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u0438, \u043d\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0438 \u0442\u0451\u043f\u043b\u044b\u0435, \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u043e\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u043d\u044f\u0445 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0441\u0432\u043e\u0451 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043e\u0442 \u0441\u0442\u0430\u0440\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <code>assetpackage PlanetWalker<\/code>. \u042d\u0442\u043e \u0431\u044b\u043b \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0438\u0433\u0440\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u0441\u043c\u043e\u0441\u0443 \u0438 \u043f\u043e\u0441\u0435\u0449\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043b\u0430\u043d\u0435\u0442\u044b, \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u044b \u0432\u044b\u0441\u043e\u0442. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043a\u0440\u043e\u043c\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u0438 \u043d\u0435\u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0435\u0448\u0430 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u0447\u0435\u0433\u043e. \u041d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044f \u0442\u043e\u0440\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043b\u044f\u043d\u0443\u0441\u044c, \u0447\u0442\u043e \u0437\u0430\u043c\u044b\u0448\u043b\u044f\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u043b\u043e\u0441\u0442\u044c&#8230;<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/web\/e43\/77b\/092\/e4377b092cea4dc1aa4596f8958288fa.PNG\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286235","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286235"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286235\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}