{"id":466387,"date":"2025-07-07T21:01:56","date_gmt":"2025-07-07T21:01:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=466387"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=466387","title":{"rendered":"<span>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0434\u0430\u043d\u0438\u0439 \u0432 Unity \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0430\u043d\u0438\u044f \u2014 \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u043c\u0438\u0440\u043e\u0432, \u0431\u0443\u0434\u044c \u0442\u043e \u043e\u0436\u0438\u0432\u043b\u0451\u043d\u043d\u044b\u0439 \u0433\u043e\u0440\u043e\u0434 \u0438\u043b\u0438 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u0430\u044f \u0434\u0435\u0440\u0435\u0432\u043d\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u044e:<\/p>\n<ul>\n<li>\n<p><strong>\u0420\u0443\u0447\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435<\/strong>: \u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u0430\u043a LEGO, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u0446\u0435\u043d \u044d\u0442\u043e \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u043b\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f<\/strong>: \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0446\u0435\u043b\u044b\u0435 \u0433\u043e\u0440\u043e\u0434\u0430, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0437\u043c<\/strong>: \u041d\u0438\u0437\u043a\u043e\u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0443\u0431\u044b \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0432\u0440\u0435\u043c\u044f, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0433\u0440\u0430 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u042f \u0445\u043e\u0442\u0435\u043b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u0435, \u0430 \u043d\u0435 \u043d\u0430 \u0440\u0443\u0447\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u0437\u0434\u0430\u043d\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432 \u0432 Unity, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0434\u0430\u043d\u0438\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0438\u0445 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0441\u0442\u0438\u043b\u0435\u043c.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u043f\u043b\u0430\u0439\u043d\u044b?<\/h3>\n<p>\u0421\u043f\u043b\u0430\u0439\u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u044d\u0442\u043e \u0437\u043e\u043b\u043e\u0442\u0430\u044f \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0443\u0447\u043d\u044b\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u043c \u0438 \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0437\u0434\u0430\u043d\u0438\u044f, \u0440\u0438\u0441\u0443\u044f \u0441\u043f\u043b\u0430\u0439\u043d \u0432 \u043e\u043a\u043d\u0435 \u0441\u0446\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u0435\u0442\u043a\u0438 (\u0441\u0442\u0435\u043d\u044b, \u043e\u043a\u043d\u0430, \u0434\u0432\u0435\u0440\u0438) \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u0438\u043b\u0438 \u043c\u0435\u043d\u044f\u044f \u0441\u0435\u0442\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u0431\u0435\u0437 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u0442\u043e\u043a, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432, \u0438 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u044b\u0448 \u0438\u043b\u0438 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u0432.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 Building Maker<\/h3>\n<h4>\u0428\u0430\u0433 1: \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 Splines \u0447\u0435\u0440\u0435\u0437 Package Manager \u0432 Unity. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043f\u043b\u0430\u0439\u043d \u0432 \u0441\u0446\u0435\u043d\u0435 \u2014 \u043e\u043d \u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0437\u0434\u0430\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 BuildingMaker \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>RequireComponent(typeof(SplineContainer)) \u2014 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>ExecuteInEditMode \u2014 \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 Awake \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043f\u043b\u0430\u0439\u043d-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0435\u0442\u043e\u043a (\u0441\u0442\u0435\u043d\u0430, \u043e\u043a\u043d\u043e, \u0434\u0432\u0435\u0440\u044c) \u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438.<\/p>\n<pre><code>[RequireComponent(typeof(SplineContainer))] [ExecuteInEditMode] public class BuildingMaker : MonoBehaviour {     private SplineContainer splineContainer;     public Mesh wallMesh, windowMesh, doorMesh;     public float distance;      void Awake() {         splineContainer = GetComponent&lt;SplineContainer&gt;();     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u0447\u0435\u043a \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 CalculatePoints, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0442\u043e\u0447\u043a\u0438 \u0438 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0448\u0438\u0440\u0438\u043d\u044b \u0441\u0435\u0442\u043a\u0438 \u0441\u0442\u0435\u043d\u044b. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetPointAtLinearDistance \u0434\u043b\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u0435\u043a. \u0412\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0432 OnValidate, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<pre><code>void OnValidate() {     if (wallMesh) distance = wallMesh.bounds.size.x;     CalculatePoints(); }  void CalculatePoints() {     var points = new List&lt;Vector3&gt;();     var tangents = new List&lt;Vector3&gt;();     var spline = splineContainer.Spline;     float t = 0, length = spline.GetLength();     while (t &lt; 1) {         spline.Evaluate(t, out var point, out var tangent, out _);         points.Add(point);         tangents.Add(tangent);         t += distance \/ length;     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0442\u043e\u0447\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OnDrawGizmosSelected:<\/p>\n<pre><code>void OnDrawGizmosSelected() {     foreach (var point in points) {         Gizmos.DrawSphere(point, 0.1f);     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u0432 OnEnable \u0438 \u043e\u0442\u043f\u0438\u0441\u043a\u0443 \u0432 OnDisable, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<h4>\u0428\u0430\u0433 3: \u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u043e\u043a<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u043e\u043a \u0438 \u0441\u043f\u0438\u0441\u043e\u043a CombineInstance \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0412 \u0446\u0438\u043a\u043b\u0435 for \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u043e \u0442\u043e\u0447\u043a\u0430\u043c, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u043a\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043c\u0435\u043d\u044f\u044f \u043e\u0441\u0438 X \u0438 Z, \u0447\u0442\u043e\u0431\u044b \u0441\u0435\u0442\u043a\u0430 &#171;\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0430&#187; \u043a\u0440\u0430\u0435\u043c \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<pre><code>public List&lt;CombineInstance&gt; instances = new List&lt;CombineInstance&gt;(); void GenerateMesh() {     instances.Clear();     for (int i = 0; i &lt; points.Count; i++) {         var point = points[i];         var tangent = tangents[i];         var direction = (i &lt; points.Count - 1 ? points[i + 1] : points[0]) - point;         var lookDir = new Vector3(tangent.z, 0, -tangent.x);         var offsetMatrix = Matrix4x4.TRS(point, Quaternion.LookRotation(lookDir), Vector3.one);         var instance = new CombineInstance { mesh = wallMesh, transform = offsetMatrix };         instances.Add(instance);     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0437\u043e\u0440\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0442\u0435\u043d\u0443 \u043f\u043e X, \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<h4>\u0428\u0430\u0433 4: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u043a\u043e\u043d \u0438 \u0434\u0432\u0435\u0440\u0435\u0439<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043d \u0438 \u0434\u0432\u0435\u0440\u0435\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, windowDistribution, doorDistribution, maxDoors). \u0412 \u0446\u0438\u043a\u043b\u0435 GenerateMesh \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u0435\u0442\u043a\u0443 (\u0441\u0442\u0435\u043d\u0430, \u043e\u043a\u043d\u043e \u0438\u043b\u0438 \u0434\u0432\u0435\u0440\u044c) \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>windowDistribution = 0: \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>windowDistribution = 1: \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440.<\/p>\n<\/li>\n<li>\n<p>windowDistribution &gt; 1: \u043e\u043a\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0432\u0435\u0440\u0435\u0439 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code>public float windowDistribution, doorDistribution; public int maxDoors; void GenerateMesh() {     int doorCount = 0;     for (int i = 0; i &lt; points.Count; i++) {         Mesh selectedMesh = wallMesh;         if (doorCount &lt; maxDoors &amp;&amp; doorDistribution &gt; 0 &amp;&amp; i % doorDistribution == 0) {             selectedMesh = doorMesh;             doorCount++;         } else if (windowDistribution == 1 &amp;&amp; Random.value &gt; 0.5f) {             selectedMesh = windowMesh;         } else if (windowDistribution &gt; 1 &amp;&amp; i % windowDistribution == 0) {             selectedMesh = windowMesh;         }         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 CombineInstance \u043a\u0430\u043a \u0432\u044b\u0448\u0435     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 5: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u0430\u0436\u0435\u0439<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e floorCount (\u043c\u0438\u043d\u0438\u043c\u0443\u043c 1). \u041e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0446\u0438\u043a\u043b \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u043e\u043a \u0432 \u0446\u0438\u043a\u043b \u043f\u043e \u044d\u0442\u0430\u0436\u0430\u043c, \u0441\u043c\u0435\u0449\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e Y \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0443 \u0441\u0442\u0435\u043d\u044b. \u0414\u0432\u0435\u0440\u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u0436\u0435.<\/p>\n<pre><code>public int floorCount = 1; void GenerateMesh() {     instances.Clear();     for (int floor = 0; floor &lt; floorCount; floor++) {         for (int i = 0; i &lt; points.Count; i++) {             var point = points[i] + Vector3.up * floor * wallMesh.bounds.size.y;             Mesh selectedMesh = (floor == 0 &amp;&amp; doorCount &lt; maxDoors &amp;&amp; i % doorDistribution == 0) ? doorMesh : (windowDistribution &gt; 1 &amp;&amp; i % windowDistribution == 0) ? windowMesh : wallMesh;             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 CombineInstance         }     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 6: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u044b\u0441\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0433\u0438\u0437\u043c\u043e<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 BuildingMakerEditor \u0434\u043b\u044f \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u044b\u0441\u043e\u0442\u044b. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 OnSceneGUI \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u0446\u0435\u043d\u0442\u0440 \u0437\u0434\u0430\u043d\u0438\u044f, \u0432\u044b\u0441\u043e\u0442\u0443 \u044d\u0442\u0430\u0436\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 FreeMoveHandle \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f floorCount.<\/p>\n<pre><code>[CustomEditor(typeof(BuildingMaker))] public class BuildingMakerEditor : Editor {     void OnSceneGUI() {         var maker = (BuildingMaker)target;         var center = maker.points.Aggregate(Vector3.zero, (sum, p) =&gt; sum + p) \/ maker.points.Count;         var floorHeight = maker.wallMesh.bounds.size.y;         var top = center + Vector3.up * floorHeight * maker.floorCount;         Handles.FreeMoveHandle(top, Quaternion.identity, 0.5f, Vector3.zero, Handles.SphereHandleCap);         \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 floorCount \u043f\u043e Y-\u043f\u043e\u0437\u0438\u0446\u0438\u0438     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 7: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u0440\u044b\u0448\u0438<\/h4>\n<p>\u0414\u043b\u044f \u043a\u0440\u044b\u0448\u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 BuildRoofMeshData. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b VertexInfo \u0438 Quad \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438 UV. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u0446\u0435\u043d\u0442\u0440 \u0437\u0434\u0430\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 quad \u0434\u043b\u044f \u043c\u0430\u043d\u0441\u0430\u0440\u0434\u043d\u043e\u0439 \u043a\u0440\u044b\u0448\u0438, \u043b\u0435\u0440\u043f\u044f \u043c\u0435\u0436\u0434\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438. \u0414\u043b\u044f \u043f\u043b\u043e\u0441\u043a\u043e\u0439 \u043a\u0440\u044b\u0448\u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 quad, \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0440\u0430\u044f \u043c\u0435\u043d\u044c\u0448\u0435 1.<\/p>\n<pre><code>struct VertexInfo { public Vector3 position; \/* \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d *\/ } struct Quad {     public Quad(Vector3[] vertices, float offset) { \/* \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d, UV, \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 *\/ } } void BuildRoofMeshData(List&lt;CombineInstance&gt; instances) {     var center = points.Aggregate(Vector3.zero, (sum, p) =&gt; sum + p) \/ points.Count;     var faces = new List&lt;Quad&gt;();     for (int i = 0; i &lt; points.Count; i++) {         var p1 = points[i] + Vector3.up * floorCount * wallMesh.bounds.size.y;         var p2 = Vector3.Lerp(p1, center, edgePoint);         \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 quad \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 faces     }     instances.Add(GetMeshFromQuads(faces)); }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 8: \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0441\u0435\u0442\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CombineMeshes \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c mergeSubMeshes = true, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c lock \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u0438\u044f \u0441\u0435\u0442\u043a\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<pre><code>public bool lock; void OnValidate() {     if (!lock) GenerateMesh(); }<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430<\/h3>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0434\u0430\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0441 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0441\u0435\u0442\u043e\u043a, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u044b\u0448 \u0438\u043b\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 Building Maker \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0434\u0430\u043d\u0438\u044f, \u044d\u043a\u043e\u043d\u043e\u043c\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0443\u0440\u043e\u0432\u043d\u0435\u0439. \u041e\u043d \u0438\u0434\u0435\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0438\u043d\u0434\u0438-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043d\u0430\u0434 \u043d\u0435\u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u043c\u0438 \u043c\u0438\u0440\u0430\u043c\u0438. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434 \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u0432\u043e\u0438 \u0441\u0435\u0442\u043a\u0438 \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. <\/p>\n<p>\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0410\u043d\u0442\u0438\u043f\u0438\u043d, \u0441\u0442\u0443\u0434\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Metabula Games<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/925706\/\"> https:\/\/habr.com\/ru\/articles\/925706\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0430\u043d\u0438\u044f \u2014 \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u043c\u0438\u0440\u043e\u0432, \u0431\u0443\u0434\u044c \u0442\u043e \u043e\u0436\u0438\u0432\u043b\u0451\u043d\u043d\u044b\u0439 \u0433\u043e\u0440\u043e\u0434 \u0438\u043b\u0438 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u0430\u044f \u0434\u0435\u0440\u0435\u0432\u043d\u044f. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u044e:<\/p>\n<ul>\n<li>\n<p><strong>\u0420\u0443\u0447\u043d\u043e\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435<\/strong>: \u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u0430\u043a LEGO, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u0446\u0435\u043d \u044d\u0442\u043e \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u043b\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f<\/strong>: \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0446\u0435\u043b\u044b\u0435 \u0433\u043e\u0440\u043e\u0434\u0430, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0437\u043c<\/strong>: \u041d\u0438\u0437\u043a\u043e\u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0443\u0431\u044b \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0432\u0440\u0435\u043c\u044f, \u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0433\u0440\u0430 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u042f \u0445\u043e\u0442\u0435\u043b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u0435, \u0430 \u043d\u0435 \u043d\u0430 \u0440\u0443\u0447\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0435 \u0437\u0434\u0430\u043d\u0438\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432 \u0432 Unity, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0434\u0430\u043d\u0438\u044f, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0438\u0445 \u0444\u043e\u0440\u043c\u043e\u0439 \u0438 \u0441\u0442\u0438\u043b\u0435\u043c.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u043f\u043b\u0430\u0439\u043d\u044b?<\/h3>\n<p>\u0421\u043f\u043b\u0430\u0439\u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2014 \u044d\u0442\u043e \u0437\u043e\u043b\u043e\u0442\u0430\u044f \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0443\u0447\u043d\u044b\u043c \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u043c \u0438 \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0437\u0434\u0430\u043d\u0438\u044f, \u0440\u0438\u0441\u0443\u044f \u0441\u043f\u043b\u0430\u0439\u043d \u0432 \u043e\u043a\u043d\u0435 \u0441\u0446\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0441\u0435\u0442\u043a\u0438 (\u0441\u0442\u0435\u043d\u044b, \u043e\u043a\u043d\u0430, \u0434\u0432\u0435\u0440\u0438) \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u0438\u043b\u0438 \u043c\u0435\u043d\u044f\u044f \u0441\u0435\u0442\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u0431\u0435\u0437 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0442\u0440\u0443\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u0442\u043e\u043a, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u043b\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432, \u0438 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u044b\u0448 \u0438\u043b\u0438 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u0432.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 Building Maker<\/h3>\n<h4>\u0428\u0430\u0433 1: \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043f\u0430\u043a\u0435\u0442 Splines \u0447\u0435\u0440\u0435\u0437 Package Manager \u0432 Unity. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043f\u043b\u0430\u0439\u043d \u0432 \u0441\u0446\u0435\u043d\u0435 \u2014 \u043e\u043d \u0441\u0442\u0430\u043d\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043e\u0439 \u0434\u043b\u044f \u0437\u0434\u0430\u043d\u0438\u044f. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 BuildingMaker \u0441 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>RequireComponent(typeof(SplineContainer)) \u2014 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>ExecuteInEditMode \u2014 \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 Awake \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043f\u043b\u0430\u0439\u043d-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0435\u0442\u043e\u043a (\u0441\u0442\u0435\u043d\u0430, \u043e\u043a\u043d\u043e, \u0434\u0432\u0435\u0440\u044c) \u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438.<\/p>\n<pre><code>[RequireComponent(typeof(SplineContainer))] [ExecuteInEditMode] public class BuildingMaker : MonoBehaviour {     private SplineContainer splineContainer;     public Mesh wallMesh, windowMesh, doorMesh;     public float distance;      void Awake() {         splineContainer = GetComponent&lt;SplineContainer&gt;();     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 2: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u0447\u0435\u043a \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 CalculatePoints, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0442\u043e\u0447\u043a\u0438 \u0438 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0448\u0438\u0440\u0438\u043d\u044b \u0441\u0435\u0442\u043a\u0438 \u0441\u0442\u0435\u043d\u044b. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e GetPointAtLinearDistance \u0434\u043b\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u0435\u043a. \u0412\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0432 OnValidate, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<pre><code>void OnValidate() {     if (wallMesh) distance = wallMesh.bounds.size.x;     CalculatePoints(); }  void CalculatePoints() {     var points = new List&lt;Vector3&gt;();     var tangents = new List&lt;Vector3&gt;();     var spline = splineContainer.Spline;     float t = 0, length = spline.GetLength();     while (t &lt; 1) {         spline.Evaluate(t, out var point, out var tangent, out _);         points.Add(point);         tangents.Add(tangent);         t += distance \/ length;     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u0442\u043e\u0447\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OnDrawGizmosSelected:<\/p>\n<pre><code>void OnDrawGizmosSelected() {     foreach (var point in points) {         Gizmos.DrawSphere(point, 0.1f);     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u0430 \u0432 OnEnable \u0438 \u043e\u0442\u043f\u0438\u0441\u043a\u0443 \u0432 OnDisable, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<h4>\u0428\u0430\u0433 3: \u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u043e\u043a<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u043e\u043a \u0438 \u0441\u043f\u0438\u0441\u043e\u043a CombineInstance \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0412 \u0446\u0438\u043a\u043b\u0435 for \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0435 \u043f\u043e \u0442\u043e\u0447\u043a\u0430\u043c, \u0437\u0430\u0434\u0430\u0432\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0442\u043a\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043c\u0435\u043d\u044f\u044f \u043e\u0441\u0438 X \u0438 Z, \u0447\u0442\u043e\u0431\u044b \u0441\u0435\u0442\u043a\u0430 &#171;\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0430&#187; \u043a\u0440\u0430\u0435\u043c \u0432\u0434\u043e\u043b\u044c \u0441\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<pre><code>public List&lt;CombineInstance&gt; instances = new List&lt;CombineInstance&gt;(); void GenerateMesh() {     instances.Clear();     for (int i = 0; i &lt; points.Count; i++) {         var point = points[i];         var tangent = tangents[i];         var direction = (i &lt; points.Count - 1 ? points[i + 1] : points[0]) - point;         var lookDir = new Vector3(tangent.z, 0, -tangent.x);         var offsetMatrix = Matrix4x4.TRS(point, Quaternion.LookRotation(lookDir), Vector3.one);         var instance = new CombineInstance { mesh = wallMesh, transform = offsetMatrix };         instances.Add(instance);     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0437\u043e\u0440\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0442\u0435\u043d\u0443 \u043f\u043e X, \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<h4>\u0428\u0430\u0433 4: \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u043a\u043e\u043d \u0438 \u0434\u0432\u0435\u0440\u0435\u0439<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043d \u0438 \u0434\u0432\u0435\u0440\u0435\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, windowDistribution, doorDistribution, maxDoors). \u0412 \u0446\u0438\u043a\u043b\u0435 GenerateMesh \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0441\u0435\u0442\u043a\u0443 (\u0441\u0442\u0435\u043d\u0430, \u043e\u043a\u043d\u043e \u0438\u043b\u0438 \u0434\u0432\u0435\u0440\u044c) \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>windowDistribution = 0: \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0435\u043d\u044b.<\/p>\n<\/li>\n<li>\n<p>windowDistribution = 1: \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440.<\/p>\n<\/li>\n<li>\n<p>windowDistribution &gt; 1: \u043e\u043a\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u0434\u0432\u0435\u0440\u0435\u0439 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e.<\/p>\n<pre><code>public float windowDistribution, doorDistribution; public int maxDoors; void GenerateMesh() {     int doorCount = 0;     for (int i = 0; i &lt; points.Count; i++) {         Mesh selectedMesh = wallMesh;         if (doorCount &lt; maxDoors &amp;&amp; doorDistribution &gt; 0 &amp;&amp; i % doorDistribution == 0) {             selectedMesh = doorMesh;             doorCount++;         } else if (windowDistribution == 1 &amp;&amp; Random.value &gt; 0.5f) {             selectedMesh = windowMesh;         } else if (windowDistribution &gt; 1 &amp;&amp; i % windowDistribution == 0) {             selectedMesh = windowMesh;         }         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 CombineInstance \u043a\u0430\u043a \u0432\u044b\u0448\u0435     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 5: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u0430\u0436\u0435\u0439<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e floorCount (\u043c\u0438\u043d\u0438\u043c\u0443\u043c 1). \u041e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u0446\u0438\u043a\u043b \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u0435\u0442\u043e\u043a \u0432 \u0446\u0438\u043a\u043b \u043f\u043e \u044d\u0442\u0430\u0436\u0430\u043c, \u0441\u043c\u0435\u0449\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e Y \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0443 \u0441\u0442\u0435\u043d\u044b. \u0414\u0432\u0435\u0440\u0438 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0439\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u044d\u0442\u0430\u0436\u0435.<\/p>\n<pre><code>public int floorCount = 1; void GenerateMesh() {     instances.Clear();     for (int floor = 0; floor &lt; floorCount; floor++) {         for (int i = 0; i &lt; points.Count; i++) {             var point = points[i] + Vector3.up * floor * wallMesh.bounds.size.y;             Mesh selectedMesh = (floor == 0 &amp;&amp; doorCount &lt; maxDoors &amp;&amp; i % doorDistribution == 0) ? doorMesh : (windowDistribution &gt; 1 &amp;&amp; i % windowDistribution == 0) ? windowMesh : wallMesh;             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 CombineInstance         }     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 6: \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u044b\u0441\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0433\u0438\u0437\u043c\u043e<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 BuildingMakerEditor \u0434\u043b\u044f \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u044b\u0441\u043e\u0442\u044b. \u0412 \u043c\u0435\u0442\u043e\u0434\u0435 OnSceneGUI \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u0446\u0435\u043d\u0442\u0440 \u0437\u0434\u0430\u043d\u0438\u044f, \u0432\u044b\u0441\u043e\u0442\u0443 \u044d\u0442\u0430\u0436\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 FreeMoveHandle \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f floorCount.<\/p>\n<pre><code>[CustomEditor(typeof(BuildingMaker))] public class BuildingMakerEditor : Editor {     void OnSceneGUI() {         var maker = (BuildingMaker)target;         var center = maker.points.Aggregate(Vector3.zero, (sum, p) =&gt; sum + p) \/ maker.points.Count;         var floorHeight = maker.wallMesh.bounds.size.y;         var top = center + Vector3.up * floorHeight * maker.floorCount;         Handles.FreeMoveHandle(top, Quaternion.identity, 0.5f, Vector3.zero, Handles.SphereHandleCap);         \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 floorCount \u043f\u043e Y-\u043f\u043e\u0437\u0438\u0446\u0438\u0438     } }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 7: \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u0440\u044b\u0448\u0438<\/h4>\n<p>\u0414\u043b\u044f \u043a\u0440\u044b\u0448\u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 BuildRoofMeshData. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b VertexInfo \u0438 Quad \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0438 UV. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435 \u0446\u0435\u043d\u0442\u0440 \u0437\u0434\u0430\u043d\u0438\u044f, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 quad \u0434\u043b\u044f \u043c\u0430\u043d\u0441\u0430\u0440\u0434\u043d\u043e\u0439 \u043a\u0440\u044b\u0448\u0438, \u043b\u0435\u0440\u043f\u044f \u043c\u0435\u0436\u0434\u0443 \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u0438 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438. \u0414\u043b\u044f \u043f\u043b\u043e\u0441\u043a\u043e\u0439 \u043a\u0440\u044b\u0448\u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 quad, \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0440\u0430\u044f \u043c\u0435\u043d\u044c\u0448\u0435 1.<\/p>\n<pre><code>struct VertexInfo { public Vector3 position; \/* \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d *\/ } struct Quad {     public Quad(Vector3[] vertices, float offset) { \/* \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0440\u0448\u0438\u043d, UV, \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432 *\/ } } void BuildRoofMeshData(List&lt;CombineInstance&gt; instances) {     var center = points.Aggregate(Vector3.zero, (sum, p) =&gt; sum + p) \/ points.Count;     var faces = new List&lt;Quad&gt;();     for (int i = 0; i &lt; points.Count; i++) {         var p1 = points[i] + Vector3.up * floorCount * wallMesh.bounds.size.y;         var p2 = Vector3.Lerp(p1, center, edgePoint);         \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 quad \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 faces     }     instances.Add(GetMeshFromQuads(faces)); }<\/code><\/pre>\n<h4>\u0428\u0430\u0433 8: \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u0435 \u0441\u0435\u0442\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e CombineMeshes \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c mergeSubMeshes = true, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u044c lock \u0434\u043b\u044f \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0435\u043a\u0430\u043d\u0438\u044f \u0441\u0435\u0442\u043a\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<pre><code>public bool lock; void OnValidate() {     if (!lock) GenerateMesh(); }<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430<\/h3>\n<p><strong>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0434\u0430\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b \u0438 \u0432\u044b\u0441\u043e\u0442\u044b \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0441 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0441\u0435\u0442\u043e\u043a, \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u043f\u043b\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043a\u0440\u044b\u0448 \u0438\u043b\u0438 \u0432\u044b\u0441\u043e\u043a\u043e\u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0438\u0437\u0430\u0439\u043d\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 Building Maker \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0434\u0430\u043d\u0438\u044f, \u044d\u043a\u043e\u043d\u043e\u043c\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0443\u0440\u043e\u0432\u043d\u0435\u0439. \u041e\u043d \u0438\u0434\u0435\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0438\u043d\u0434\u0438-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043d\u0430\u0434 \u043d\u0435\u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u043c\u0438 \u043c\u0438\u0440\u0430\u043c\u0438. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0434 \u0432\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u0432\u043e\u0438 \u0441\u0435\u0442\u043a\u0438 \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. <\/p>\n<p>\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0410\u043d\u0442\u0438\u043f\u0438\u043d, \u0441\u0442\u0443\u0434\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Metabula Games<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/925706\/\"> https:\/\/habr.com\/ru\/articles\/925706\/<\/a><br \/><\/br><\/br><\/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-466387","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/466387","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=466387"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/466387\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}