{"id":1881,"date":"2022-08-04T16:17:00","date_gmt":"2022-08-04T16:17:00","guid":{"rendered":"https:\/\/golemitegames.com\/?post_type=docs&#038;p=1881"},"modified":"2022-08-04T16:33:06","modified_gmt":"2022-08-04T16:33:06","password":"","slug":"objectremover","status":"publish","type":"docs","link":"https:\/\/golemitegames.com\/index.php\/docs\/objectremover\/","title":{"rendered":"ObjectRemover"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void RemoveObject(GameObject objToRemove, GridObject.Data gridObjectData)<\/h2>\n\n\n\n<p>This function removes the given <strong>objToRemove<\/strong> using the <strong>gridObjectData<\/strong> to find the grid and checkPositions to unblock. <\/p>\n\n\n\n<p>Currently <strong>gridObjectData<\/strong> is formulated at placement time and fairly troublesome to replicate. If you want to remove objects from the grid via code, consider using the below method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void RemoveObject(GameObject objToRemove, List checkPositions, GridSquare grid)<\/h2>\n\n\n\n<p>This version of the RemoveObject unblocks the cell at the <strong>checkPositions<\/strong> on <strong>grid<\/strong> and destroys the <strong>objToRemove<\/strong>.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>public Button btn;\npublic ObjectRemover objectRemover;\n\nbtn.onClick.AddListener(() =&gt;\n{\n    objectRemover.RemoveObject(removeObj, \n    removeObj.GetComponent&lt;GridObject&gt;().data.CheckPositions, \n    removeObj.GetComponent&lt;GridObject&gt;().data.GridSquare);\n});<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void RemoveObjectsOfType(int prefabId = 0)<\/h2>\n\n\n\n<p>Given a <strong>prefabId<\/strong>, which is set via the <strong>SelectObject<\/strong> btn, will destroy all objects placed with that <strong>prefabId<\/strong>. <\/p>\n\n\n\n<p class=\"has-background-color has-text-color\">Note, this method does <strong>not<\/strong> unblock cells, only destroys the GameObjects. You will need to call <strong>ObjectStorage.GetObjectsOfType<\/strong> to get a <strong>List<\/strong> of all the GameObjects first and unblock all cells before calling this method.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>public Button btn;\npublic ObjectRemover objectRemover;\n\nbtn.onClick.AddListener(() =&gt;\n{\n    \/\/Removes all placed objects with given prefabId of 1\n    objectRemover.RemoveObjectsOfType(1);\n});<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void RemoveObjectByInstanceId(string id)<\/h2>\n\n\n\n<p>Given a unique <strong>id<\/strong> which is set upon object creation via the <strong>ObjectPlacer<\/strong>, destroys that particular object. <\/p>\n\n\n\n<p class=\"has-background-color has-text-color\">Note, this method does <strong>not<\/strong> unblock cells, only destroys the GameObject. You will need to call search the <strong>Dictionary GOInstanceList<\/strong> in <strong>ObjectStorage<\/strong> to get the GameObject first and unblock all cells before calling this method.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-csharp\" data-lang=\"C#\"><code>public Button btn;\npublic ObjectRemover objectRemover;\nGameObject objToRemove;\n\nbtn.onClick.AddListener(() =&gt;\n{\n    \/\/Removes the object with the given InstanceId\n    objectRemover.RemoveObjectByInstanceId(objectToRemove.getComponent&lt;GridObject&gt;().data.InstanceId);\n});<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"font-size:22px\">public void UnblockCells(List checkPositions, GridSquare grid)<\/h2>\n\n\n\n<p>Unblocks the cells with the given <strong>checkPositions<\/strong> on the given <strong>grid<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>public void RemoveObject(GameObject objToRemove, GridObject.Data gridObjectData) This function removes the given objToRemove using the gridObjectData to find the grid and checkPositions to unblock. Currently gridObjectData is formulated at placement time and fairly troublesome to replicate. If you want to remove objects from the grid via code, consider using the below method. public void RemoveObject(GameObject objToRemove, [&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-1881","docs","type-docs","status-publish","hentry","doc_category-scripting-gridbuilder2"],"acf":[],"aioseo_notices":[],"year_month":"2026-04","word_count":287,"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\/1881","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=1881"}],"version-history":[{"count":13,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/1881\/revisions"}],"predecessor-version":[{"id":1904,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/docs\/1881\/revisions\/1904"}],"wp:attachment":[{"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/media?parent=1881"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_category?post=1881"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/golemitegames.com\/index.php\/wp-json\/wp\/v2\/doc_tag?post=1881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}