{"id":262,"date":"2019-04-28T19:55:46","date_gmt":"2019-04-28T19:55:46","guid":{"rendered":"https:\/\/docs.sisus.co\/power-inspector\/?p=262"},"modified":"2019-10-26T12:31:05","modified_gmt":"2019-10-26T12:31:05","slug":"modifying-existing-drawers","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/power-inspector\/extending-power-inspector\/modifying-existing-drawers\/","title":{"rendered":"09. Modifying Existing Drawers"},"content":{"rendered":"<p>If you want to modify an existing <a href=\"https:\/\/docs.sisus.co\/power-inspector\/terminology\/drawer\/\">drawer<\/a> that ships with Power Inspector, it is <strong>not<\/strong> recommended to do this by directly editing the class file. This could result in conflicts if future updates to Power Inspector should change the same file.<\/p>\n<p>Instead you should create your own class that <strong>extends<\/strong> the drawer you want to modify, and implement your modifications by way of <strong>overriding<\/strong> methods and properties.<\/p>\n<p>To get Power Inspector to start using your drawer instead of the original one, you&#8217;ll also need to copy the DrawerFor* attribute from the base class declaration, except omitting the last <strong>&#8220;setIsFallback&#8221;<\/strong> parameter.<\/p>\n<h2>Example<\/h2>\n<pre>using UnityEngine;\r\nusing Sisus;\r\nusing Sisus.Attributes;\r\n\r\n[DrawerForComponent(typeof(Transform), false)]\r\npublic class ExtendedTransformDrawer : TransformDrawer\r\n{\r\n\t\t\/\/\/ &lt;inheritdoc\/&gt;\r\n\t\tprotected override void BuildContextMenu(ref Menu menu, bool extendedMenu)\r\n\t\t{\r\n\t\t\tbase.BuildContextMenu(ref menu, extendedMenu);\r\n\t\t\tmenu.AddSeparatorIfNotRedundant();\r\n\t\t\tmenu.Add(\"Print Name To Console\", ()=&gt;Debug.Log(Name));\r\n\t\t}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you want to modify an existing drawer that ships with Power Inspector, it is not recommended to do this by directly editing the class file. This could result in conflicts if future updates to Power Inspector should change the same file. Instead you should create your own class that extends the drawer you want ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/power-inspector\/extending-power-inspector\/modifying-existing-drawers\/\" title=\"read more\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/262"}],"collection":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/comments?post=262"}],"version-history":[{"count":6,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/262\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/262\/revisions\/1316"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/media?parent=262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/categories?post=262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/tags?post=262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}