{"id":1761,"date":"2020-10-19T18:59:02","date_gmt":"2020-10-19T18:59:02","guid":{"rendered":"https:\/\/docs.sisus.co\/power-inspector\/?p=1761"},"modified":"2020-10-19T19:02:12","modified_gmt":"2020-10-19T19:02:12","slug":"field-values-not-being-saved-into-scene","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/power-inspector\/troubleshooting\/field-values-not-being-saved-into-scene\/","title":{"rendered":"Field Values Not Being Saved"},"content":{"rendered":"<h3>The Problem<\/h3>\n<div>You have <strong><a href=\"https:\/\/docs.sisus.co\/power-inspector\/getting-started\/class-member-visibility\/\">exposed some fields<\/a><\/strong> in Power Inspector using an attribute like <strong><a href=\"https:\/\/docs.sisus.co\/power-inspector\/attributes\/showininspector\/\">ShowInInspector<\/a><\/strong> or <strong><a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/SerializeField.html\">SerializeField<\/a><\/strong>. However, whenever you enter play mode or restart unity all the changes you&#8217;ve made to these fields are lost.<\/div>\n<h3>The Reason<\/h3>\n<div>Power Inspector will display any field that contains the aforementioned attributes, but this does not necessarily mean that their values are being <strong><a href=\"https:\/\/docs.unity3d.com\/Manual\/script-Serialization.html\">serialized<\/a><\/strong>. If a field&#8217;s value is not being saved into the scene file, any changes you made will be nowhere to be found when the scene is loaded from disk the next time.<\/div>\n<h3><strong>The Solution<\/strong><\/h3>\n<p>Instead of using the SerializeField attribute, try using the <strong><a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/SerializeReference.html\">SerializerReference<\/a><\/strong> attribute instead. With this attribute Unity will serialize field values even for abstract and generic types.<\/p>\n<div class=\"_3xC-c\">\n<p>In the rare instances where even SerializeReference doesn&#8217;t work either (like with dictionaries) you\u2019ll need to <strong><a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/ISerializationCallbackReceiver.html\">handle serialization manually<\/a><\/strong>.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Problem You have exposed some fields in Power Inspector using an attribute like ShowInInspector or SerializeField. However, whenever you enter play mode or restart unity all the changes you&#8217;ve made to these fields are lost. The Reason Power Inspector will display any field that contains the aforementioned attributes, but this does not necessarily mean ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/power-inspector\/troubleshooting\/field-values-not-being-saved-into-scene\/\" 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":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1761"}],"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=1761"}],"version-history":[{"count":5,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1761\/revisions"}],"predecessor-version":[{"id":1766,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/posts\/1761\/revisions\/1766"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/media?parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/categories?post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/power-inspector\/wp-json\/wp\/v2\/tags?post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}