{"id":1846,"date":"2022-08-01T15:25:07","date_gmt":"2022-08-01T15:25:07","guid":{"rendered":"https:\/\/golemitegames.com\/?post_type=docs&#038;p=1846"},"modified":"2022-08-01T15:51:13","modified_gmt":"2022-08-01T15:51:13","password":"","slug":"gridselector-2","status":"publish","type":"docs","link":"https:\/\/golemitegames.com\/index.php\/docs\/gridselector-2\/","title":{"rendered":"GridSelector"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\"><strong><strong>public void ShowHideSelectorAndPreview()<\/strong><\/strong><\/h2>\n\n\n\n<p>This will force the grid selector to check again if cells are valid for placement for the current positions. It is called on every cell move, and after certain actions such as placing and removing objects.<\/p>\n\n\n\n<p>Use this function when you need to manually recheck cell validity. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void PlaceObjectIfEmpty(GridSquare currentGrid)<\/h2>\n\n\n\n<p>This function will set up the data necessary for the <strong>ObjectPlacer<\/strong>. This function uses a lot of data stored at the time of calling <strong>SetGameObjectToPlace<\/strong> as well as positional and rotational data stored in the <strong>GridSelector<\/strong>. <\/p>\n\n\n\n<p>If you are calling this outside of using <strong>SetGameObjectToPlace<\/strong> some of the data stored may not be null. <\/p>\n\n\n\n<p>This function also checks when calling if the cells are clear to place. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\"><strong><strong>public void ChangeObjMat(GameObject obj, Material newMat)<\/strong><\/strong><\/h2>\n\n\n\n<p>This will loop through all children of the obj including itself and through all assigned materials and assign the newMat to each of them.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>\/\/Changes the obj material to something else.\nGridSelector gridSelector;\n\nvoid Start() \n{\n    gridSelector.ChangeObjMat(myObjectToChange, invalidMaterial);\n} \n<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\"><strong><strong>public void ChangePreviewObjLayer(GameObject obj, int newLayer)<\/strong><\/strong><\/h2>\n\n\n\n<p>This changes the given <strong>obj<\/strong> and its children to layer <strong>newLayer<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\"><strong>public void DeselectPreview()<\/strong><\/h2>\n\n\n\n<p>This function destroys the preview object from the hierarchy and sets the object to place as null.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>\/\/Remove the previewing of the object assigned when pressing escape.\nGridSelector gridSelector;\n\nvoid Update() \n{\n    if(Input.GetKeyDown(KeyCode.Escape))\n    {\n        gridSelector.DeselectPreview();\n    } \n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\"><strong>public void SetGameObjectToPlace(GameObject obj, SelectObject.ObjectSize objSize = null, bool moveOnPoints = false, int id = 0, int buildTime = 0, string instanceId = null)<\/strong><\/h2>\n\n\n\n<p>This takes in the <strong>obj<\/strong>, and sets it for the Grid Selector to preview and place the object.<\/p>\n\n\n\n<p>Most of the parameters here are optional, however it is best used from a <strong>SelectObject<\/strong> button for best results as all of the information will be sent. See <a href=\"https:\/\/golemitegames.com\/index.php\/docs\/setting-up-the-selectobject-button\/\" title=\"Setting up the SelectObject button\">Setting up the SelectObject button<\/a>.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>\/\/Takes an object from a button to place on the grid selector.\nGridSelector gridSelector;\n\n\/\/The prefab to send to the grid selector to place\npublic GameObject prefab;\n\nvoid Awake() \n{\n    btn = GetComponent&lt;Button&gt;();\n}\nvoid Start() \n{\n    btn.onClick.AddListener(() =&gt; {\n        gridSelector.SetGameObjectToPlace(prefab); \n    });\n}<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>public void ShowHideSelectorAndPreview() This will force the grid selector to check again if cells are valid for placement for the current positions. It is called on every cell move, and after certain actions such as placing and removing objects. Use this function when you need to manually recheck cell validity. public void PlaceObjectIfEmpty(GridSquare currentGrid) This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"doc_category":[45],"doc_tag":[],"class_list":["post-1846","docs","type-docs","status-publish","hentry","doc_category-scripting-gridbuilder2"],"acf":[],"aioseo_notices":[],"year_month":"2026-04","word_count":340,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"rickitz5h","author_nicename":"rickitz5h","author_url":"https:\/\/golemitegames.com\/index.php\/author\/rickitz5h\/"},"doc_category_info":[{"term_name":"Scripting","term_url":"https:\/\/golemitegames.com\/index.php\/docs-category\/scripting-gridbuilder2\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/1846","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/comments?post=1846"}],"version-history":[{"count":8,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/1846\/revisions"}],"predecessor-version":[{"id":1855,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/1846\/revisions\/1855"}],"wp:attachment":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/media?parent=1846"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_category?post=1846"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_tag?post=1846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}