{"id":1596,"date":"2019-12-11T19:30:45","date_gmt":"2019-12-11T19:30:45","guid":{"rendered":"https:\/\/docs.sisus.co\/power-inspector\/?p=1596"},"modified":"2019-12-11T19:30:45","modified_gmt":"2019-12-11T19:30:45","slug":"notnullmembers","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/power-inspector\/attributes\/notnullmembers\/","title":{"rendered":"NotNullMembers"},"content":{"rendered":"<p>When added before a collection type class member, indicates that the value of any of its members can not be null.<\/p>\n<p>Any member whose value is null will be highlighted with red color in the <a href=\"https:\/\/docs.sisus.co\/power-inspector\/terminology\/inspector-view\/\"><strong>inspector view<\/strong><\/a>.<\/p>\n<h2>Attribute Target<\/h2>\n<p>Field, property, indexer, method return value or method parameter.<br \/>\nTarget type must be a collection of some sort (e.g. Array or List).<\/p>\n<h2>Example<\/h2>\n<pre>using UnityEngine;\r\nusing Sisus.Attributes;\r\n\r\npublic class MissingScriptDetector : MonoBehaviour\r\n{\r\n\t[NotNullMembers, ReadOnly, ShowInInspector]\r\n\tprivate Component[] components;\r\n\r\n\t\/\/ called when the script is loaded or a value is changed in the inspector\r\n\tvoid OnValidate()\r\n\t{\r\n\t\tcomponents = GetComponents&lt;Component&gt;();\r\n\r\n\t\tfor(int n = 0, count = components.Length; n &lt; count; n++)\r\n\t\t{\r\n\t\t\tif(components[n] == null)\r\n\t\t\t{\r\n\t\t\t\tDebug.LogWarning(\"Missing component found on GameObject \"+name, gameObject);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When added before a collection type class member, indicates that the value of any of its members can not be null. Any member whose value is null will be highlighted with red color in the inspector view. Attribute Target Field, property, indexer, method return value or method parameter. Target type must be a collection of ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/power-inspector\/attributes\/notnullmembers\/\" 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\/1596"}],"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=1596"}],"version-history":[{"count":1,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":1600,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1596\/revisions\/1600"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/media?parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/categories?post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/tags?post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}