{"id":1605,"date":"2019-12-11T20:32:05","date_gmt":"2019-12-11T20:32:05","guid":{"rendered":"https:\/\/docs.sisus.co\/power-inspector\/?p=1605"},"modified":"2021-03-24T17:53:15","modified_gmt":"2021-03-24T17:53:15","slug":"showininspector","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/power-inspector\/attributes\/showininspector\/","title":{"rendered":"ShowInInspector"},"content":{"rendered":"<p>Attribute that can be used to make class member that follows the attribute be shown in the inspector.<\/p>\n<p>Unlike Unity&#8217;s built-in <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/SerializeField.html\">SerializeField<\/a> and <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/SerializeReference.html\">SerializeReference<\/a> attributes this can also be used to display non-serialized fields. It also supports exposing properties and methods in addition to fields.<\/p>\n<p>For more information see the <strong><a href=\"https:\/\/docs.sisus.co\/power-inspector\/features\/display-anything\/\">display anything<\/a><\/strong> feature page.<\/p>\n<blockquote><p>Note: fields are not automatically <a href=\"https:\/\/docs.unity3d.com\/Manual\/script-Serialization.html\"><strong>serialized<\/strong><\/a> even if this attribute is used as it only affects visibility!<br \/>\nIf you also want the field to be serialized use the <strong><a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/SerializeReference.html\">SerializeReference attribute<\/a><\/strong>.<\/p><\/blockquote>\n<h2>Attribute Target<\/h2>\n<p>Field, property, method or indexer.<\/p>\n<h2>Example<\/h2>\n<pre>using UnityEngine;\r\nusing Sisus.Attributes;\r\n\r\npublic class TestShowInInspector : MonoBehaviour\r\n{\r\n\t[ShowInInspector]\r\n\tprivate bool nonSerializedFieldSupport = true;\r\n\r\n\t[ShowInInspector]\r\n\tpublic bool PropertySupport\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tset\r\n\t\t{\r\n\t\t\tDebug.Log((value ? \"Correct.\" : \"Incorrect.\") + \" Properties are supported.\");\r\n\t\t}\r\n\t}\r\n\r\n\t[ShowInInspector]\r\n\tpublic bool GetOnlyPropertySupport { get; } = true;\r\n\r\n\t[ShowInInspector]\r\n\tpublic bool SetOnlyPropertySupport\r\n\t{\r\n\t\tset\r\n\t\t{\r\n\t\t\tDebug.Log((value ? \"Correct.\" : \"Incorrect.\") + \" Set Only Properties are supported.\");\r\n\t\t}\r\n\t}\r\n\r\n\t[ShowInInspector]\r\n\tprivate bool Method()\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t[ShowInInspector]\r\n\tprivate static bool ExposedStaticMethod()\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\r\n\t[ShowInInspector]\r\n\tprivate static bool ExposedMethodWithParameters(bool isSupported = true)\r\n\t{\r\n\t\tDebug.Log((isSupported ? \"Correct.\" : \"Incorrect.\") + \" Methods with parameters are supported.\");\r\n\t\treturn true;\r\n\t}\r\n}<\/pre>\n<h2>Example Result<\/h2>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-202\" src=\"https:\/\/docs.sisus.co\/power-inspector\/wp-content\/uploads\/2019\/04\/DisplayAnything.png\" alt=\"\" width=\"594\" height=\"255\" srcset=\"https:\/\/docs.sisus.co\/power-inspector\/wp-content\/uploads\/sites\/2\/2019\/04\/DisplayAnything.png 594w, https:\/\/docs.sisus.co\/power-inspector\/wp-content\/uploads\/sites\/2\/2019\/04\/DisplayAnything-300x129.png 300w, https:\/\/docs.sisus.co\/power-inspector\/wp-content\/uploads\/sites\/2\/2019\/04\/DisplayAnything-150x64.png 150w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><strong>See Also: <a href=\"https:\/\/docs.sisus.co\/power-inspector\/attributes\/button\/\">Button<\/a><\/strong><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Attribute that can be used to make class member that follows the attribute be shown in the inspector. Unlike Unity&#8217;s built-in SerializeField and SerializeReference attributes this can also be used to display non-serialized fields. It also supports exposing properties and methods in addition to fields. For more information see the display anything feature page. Note: ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/power-inspector\/attributes\/showininspector\/\" 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":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1605"}],"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=1605"}],"version-history":[{"count":5,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1605\/revisions"}],"predecessor-version":[{"id":1843,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1605\/revisions\/1843"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/media?parent=1605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/categories?post=1605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/tags?post=1605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}