{"id":2765,"date":"2021-01-03T10:13:39","date_gmt":"2021-01-03T09:13:39","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=2765"},"modified":"2023-06-26T15:48:05","modified_gmt":"2023-06-26T13:48:05","slug":"unity3d-snap-object-in-editor-grid","status":"publish","type":"post","link":"https:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/","title":{"rendered":"Unity3D &#8211; Snap object in editor grid"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Welcome back,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I want to share a way to draw in <strong>Unity3d editor<\/strong> a cubes based <strong>grid<\/strong> that allow you to snap objects in the same position and make a cube grid, like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/example.gif?resize=640%2C480&#038;ssl=1\" alt=\"\" class=\"wp-image-2789\"\/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">First of all, create a new Cube object using <strong>Quads<\/strong>: compose all the 6 faces and save it as a prefab.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"848\" height=\"896\" data-id=\"2769\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.27.30.png?resize=848%2C896&#038;ssl=1\" alt=\"\" class=\"wp-image-2769\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.27.30.png?w=848&amp;ssl=1 848w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.27.30.png?resize=284%2C300&amp;ssl=1 284w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.27.30.png?resize=768%2C811&amp;ssl=1 768w\" sizes=\"auto, (max-width: 848px) 100vw, 848px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"736\" data-id=\"2770\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.30.08.png?resize=730%2C736&#038;ssl=1\" alt=\"\" class=\"wp-image-2770\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.30.08.png?w=730&amp;ssl=1 730w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.30.08.png?resize=298%2C300&amp;ssl=1 298w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.30.08.png?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.30.08.png?resize=100%2C100&amp;ssl=1 100w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Align all the faces and save as Prefab.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"330\" height=\"348\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.31.14.png?resize=330%2C348&#038;ssl=1\" alt=\"\" class=\"wp-image-2771\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.31.14.png?w=330&amp;ssl=1 330w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.31.14.png?resize=284%2C300&amp;ssl=1 284w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Now on the &#8220;<strong>Top<\/strong>&#8221; face of your cube, add an empty Object and attach a <strong>Text Renderer<\/strong> and a <strong>Text Mesh<\/strong>, for adding a new label:<\/p>\n\n\n\n<figure class=\"wp-block-gallery aligncenter has-nested-images columns-default wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/schermata-2021-01-02-alle-14-33-20-1\/\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"460\" data-id=\"2780\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.33.20-1.png?resize=486%2C460&#038;ssl=1\" alt=\"\" class=\"wp-image-2780\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.33.20-1.png?w=486&amp;ssl=1 486w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.33.20-1.png?resize=300%2C284&amp;ssl=1 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/schermata-2021-01-02-alle-14-34-43-1\/\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"1024\" data-id=\"2779\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.34.43-1-531x1024.png?resize=531%2C1024&#038;ssl=1\" alt=\"\" class=\"wp-image-2779\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.34.43-1.png?resize=531%2C1024&amp;ssl=1 531w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.34.43-1.png?resize=156%2C300&amp;ssl=1 156w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.34.43-1.png?w=718&amp;ssl=1 718w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Center it on your cube, adjust font and size and you should see something like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"914\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.38.54.png?resize=896%2C914&#038;ssl=1\" alt=\"\" class=\"wp-image-2785\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.38.54.png?w=896&amp;ssl=1 896w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.38.54.png?resize=294%2C300&amp;ssl=1 294w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.38.54.png?resize=768%2C783&amp;ssl=1 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>0.0<\/strong> are respectively the X and the Y position of your cube.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Let&#8217;s code!<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add a new C# script and assign on your prefab. Call it &#8220;<strong>EditorSnap.cs<\/strong>&#8221; and open it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We introduce &#8220;[<code>ExecuteInEditMode<\/code>]&#8221; a behaviour that makes all instances of a script execute in Edit Mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/ExecuteInEditMode.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.unity3d.com\/ScriptReference\/ExecuteInEditMode.html<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the example code and try it. If it works let&#8217;s go to edit our script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\n\/\/ Makes all instances of a script execute in Edit Mode\n[ExecuteInEditMode]\n[SelectionBase]\n\npublic class EditorSnap : MonoBehaviour\n{\n    \/\/ Add an editor field, \"SerializeField\" with a custom range slider, from 1 to 20. Default value is 10.\n    [SerializeField] [Range(1f, 20f)] float gridSize = 10f;\n\n    \/\/ Attach your label\n    TextMesh textMesh;\n\n    void Update()\n    {\n        Vector3 snapPosition;\n        \/\/ When position of your object change, apply a new position on the x and y axed, based on your grid size.\n        snapPosition.x = Mathf.RoundToInt(transform.position.x \/ gridSize) * gridSize;\n        snapPosition.z = Mathf.RoundToInt(transform.position.z \/ gridSize) * gridSize;\n\n        \/\/ Put as text of your label the coordinates\n        textMesh = GetComponentInChildren&lt;TextMesh&gt;();\n        textMesh.text = snapPosition.x \/ gridSize + \".\" + snapPosition.z \/ gridSize;\n        \n        \/\/ Apply transformation\n        transform.position = new Vector3(snapPosition.x, 0f, snapPosition.z);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now your script is ready.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you duplicate your prefab and try to move, you move following the 10 size step. Try it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this simple way you&#8217;re able to create grid easily via editor, following sizes and easily snapped to the position you need.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Hint<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your prefab is a <strong>little smaller<\/strong> that the <strong>grid size<\/strong>, you are able to add a <strong>space<\/strong> between blocks, like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i2.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?fit=525%2C332&amp;ssl=1\" alt=\"\" class=\"wp-image-2798\" width=\"671\" height=\"424\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?w=2090&amp;ssl=1 2090w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?resize=300%2C190&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?resize=1024%2C648&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?resize=768%2C486&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?resize=1536%2C972&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.15.png?resize=2048%2C1295&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Or if you prefer, use the same size to create an <strong>uniformed grid<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i2.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?fit=525%2C334&amp;ssl=1\" alt=\"\" class=\"wp-image-2799\" width=\"672\" height=\"428\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?w=2094&amp;ssl=1 2094w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?resize=300%2C191&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?resize=1024%2C651&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?resize=768%2C489&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?resize=1536%2C977&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-10.07.35.png?resize=2048%2C1303&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Hint^2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you need to rename all of your cubes, add this piece of code in your script:<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"396\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-15.41.53.png?resize=434%2C396\" alt=\"unity3d rename objects from code\" class=\"wp-image-2803\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-15.41.53.png?w=434&amp;ssl=1 434w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-03-alle-15.41.53.png?resize=300%2C274&amp;ssl=1 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><figcaption class=\"wp-element-caption\">Objects take the name of their position axes.<\/figcaption><\/figure>\n<\/div>\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">string posText = snapPosition.x \/ gridSize + \".\" + snapPosition.z \/ gridSize;\ntextMesh.text = posText;\n\n\/\/ Rename objects in editor\ngameObject.name = posText;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-vivid-green-cyan-color has-css-opacity has-vivid-green-cyan-background-color has-background\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Enjoy and share your result!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back, I want to share a way to draw in Unity3d editor a cubes based grid that allow you to snap objects in the same position and make a cube grid, like this:<\/p>\n","protected":false},"author":1,"featured_media":2766,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"#Unity3D - Snap object in editor grid","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,217,8],"tags":[975,970,322,974,835,602,971,296,969,972,973,39,604],"class_list":["post-2765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c","category-development","category-unity3d","tag-c-4","tag-cube","tag-editor","tag-executeineditmode","tag-grid","tag-map","tag-quad","tag-script","tag-snap","tag-text-mesh","tag-text-renderer","tag-unity","tag-unity3d"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Unity3D - Snap object in editor grid - while (true) {\u00a0}<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity3D - Snap object in editor grid - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"Welcome back, I want to share a way to draw in Unity3d editor a cubes based grid that allow you to snap objects in the same position and make a cube grid, like this:\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-03T09:13:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-26T13:48:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226\" \/>\n\t<meta property=\"og:image:width\" content=\"2080\" \/>\n\t<meta property=\"og:image:height\" content=\"1226\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"Unity3D &#8211; Snap object in editor grid\",\"datePublished\":\"2021-01-03T09:13:39+00:00\",\"dateModified\":\"2023-06-26T13:48:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/\"},\"wordCount\":296,\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1\",\"keywords\":[\"c#\",\"cube\",\"editor\",\"executeineditmode\",\"grid\",\"map\",\"quad\",\"script\",\"snap\",\"text mesh\",\"text renderer\",\"unity\",\"unity3d\"],\"articleSection\":[\"c#\",\"development\",\"unity3d\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/\",\"name\":\"Unity3D - Snap object in editor grid - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1\",\"datePublished\":\"2021-01-03T09:13:39+00:00\",\"dateModified\":\"2023-06-26T13:48:05+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1\",\"width\":2080,\"height\":1226},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/unity3d-snap-object-in-editor-grid\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity3D &#8211; Snap object in editor grid\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unity3D - Snap object in editor grid - while (true) {\u00a0}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/","og_locale":"en_US","og_type":"article","og_title":"Unity3D - Snap object in editor grid - while (true) {\u00a0}","og_description":"Welcome back, I want to share a way to draw in Unity3d editor a cubes based grid that allow you to snap objects in the same position and make a cube grid, like this:","og_url":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2021-01-03T09:13:39+00:00","article_modified_time":"2023-06-26T13:48:05+00:00","og_image":[{"width":2080,"height":1226,"url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226","type":"image\/png"}],"author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#article","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/"},"author":{"name":"Alberto Pasca","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"Unity3D &#8211; Snap object in editor grid","datePublished":"2021-01-03T09:13:39+00:00","dateModified":"2023-06-26T13:48:05+00:00","mainEntityOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/"},"wordCount":296,"publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1","keywords":["c#","cube","editor","executeineditmode","grid","map","quad","script","snap","text mesh","text renderer","unity","unity3d"],"articleSection":["c#","development","unity3d"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/","url":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/","name":"Unity3D - Snap object in editor grid - while (true) {\u00a0}","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#primaryimage"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1","datePublished":"2021-01-03T09:13:39+00:00","dateModified":"2023-06-26T13:48:05+00:00","breadcrumb":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#primaryimage","url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1","width":2080,"height":1226},{"@type":"BreadcrumbList","@id":"http:\/\/www.albertopasca.it\/whiletrue\/unity3d-snap-object-in-editor-grid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"Unity3D &#8211; Snap object in editor grid"}]},{"@type":"WebSite","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website","url":"https:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2021\/01\/Schermata-2021-01-02-alle-14.25.49.png?fit=2080%2C1226&ssl=1","_links":{"self":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/2765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=2765"}],"version-history":[{"count":27,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/2765\/revisions"}],"predecessor-version":[{"id":3373,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/2765\/revisions\/3373"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media\/2766"}],"wp:attachment":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=2765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=2765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=2765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}