{"id":652,"date":"2025-02-25T18:30:28","date_gmt":"2025-02-25T18:30:28","guid":{"rendered":"https:\/\/docs.sisus.co\/init-args\/?p=652"},"modified":"2025-07-14T19:28:20","modified_gmt":"2025-07-14T19:28:20","slug":"unnecessary-init-section","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/init-args\/problems-and-solutions\/unnecessary-init-section\/","title":{"rendered":"Unnecessary Init Section"},"content":{"rendered":"<h1>Issue<\/h1>\n<p>You have a component that derives from <a href=\"https:\/\/docs.sisus.co\/init-args\/clients\/monobehaviour-t\/\">MonoBehaviour&lt;T&#8230;&gt;<\/a> or implements <a href=\"https:\/\/docs.sisus.co\/init-args\/reference\/iinitializable\/\">IInitializable&lt;T&#8230;&gt;<\/a>, but you don&#8217;t want the Init section to be drawn in the Inspector.<\/p>\n<p>One possible reason for this could be that the component only needs to receive Init arguments when it is being initialized at runtime using AddComponent, but never when it is attached to a GameObject in Edit Mode. The component could, for example, rely on serialized fields to receive its dependencies when it is loaded as part of a scene or a prefab.<\/p>\n<p>Another reason could be that the component only depends on <a href=\"https:\/\/docs.sisus.co\/init-args\/reference\/global-services\/\">global services<\/a>, which you know will always be available at runtime, so you find that showing the Init section is unnecessary.<\/p>\n<h1>Solution: Hide Init Section<\/h1>\n<p>You can hide the Init section for all components of a particular type by adding the <a href=\"https:\/\/docs.sisus.co\/init-args\/reference\/init-attribute\/\">[Init] attribute<\/a>\u00a0to the component\u2019s class and setting <em>HideInInspector<\/em> to <strong>true<\/strong>:<\/p>\n<pre><span class=\"line_wrapper\">[Init<span style=\"color: #308080;\">(<\/span>HideInInspector <span style=\"color: #308080;\">=<\/span> <span style=\"color: #200080; font-weight: bold;\">true<\/span><span style=\"color: #308080;\">)<\/span>]\r\n<\/span><span class=\"line_wrapper\"><span style=\"color: #200080; font-weight: bold;\">class<\/span> <span style=\"color: #005fd2;\">Client<\/span> <span style=\"color: #308080;\">:<\/span> MonoBehaviour<span style=\"color: #308080;\">&lt;<\/span>IInputManager<span style=\"color: #308080;\">&gt;<\/span><\/span><\/pre>\n<p>Alternatively you can do the same using the Inspector by disabling the <em>Show Init Section<\/em> item using the context menu of any component of the type in question:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-684\" src=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2021\/07\/toggle-show-init-section.png\" alt=\"\" width=\"369\" height=\"294\" srcset=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2021\/07\/toggle-show-init-section.png 369w, https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2021\/07\/toggle-show-init-section-300x239.png 300w\" sizes=\"(max-width: 369px) 100vw, 369px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Issue You have a component that derives from MonoBehaviour&lt;T&#8230;&gt; or implements IInitializable&lt;T&#8230;&gt;, but you don&#8217;t want the Init section to be drawn in the Inspector. One possible reason for this could be that the component only needs to receive Init arguments when it is being initialized at runtime using AddComponent, but never when it is ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/init-args\/problems-and-solutions\/unnecessary-init-section\/\" title=\"read more\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts\/652"}],"collection":[{"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":4,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":773,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts\/652\/revisions\/773"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}