{"id":580,"date":"2024-12-28T08:59:21","date_gmt":"2024-12-28T08:59:21","guid":{"rendered":"https:\/\/docs.sisus.co\/init-args\/?p=580"},"modified":"2025-07-14T19:29:02","modified_gmt":"2025-07-14T19:29:02","slug":"embedded-value-providers-in-prefabs","status":"publish","type":"post","link":"https:\/\/docs.sisus.co\/init-args\/problems-and-solutions\/embedded-value-providers-in-prefabs\/","title":{"rendered":"Embedded Value Providers in Prefabs"},"content":{"rendered":"<h1>Issue<\/h1>\n<p>Due to a limitation with Unity&#8217;s serialization system, <a href=\"https:\/\/docs.sisus.co\/init-args\/initializers\/value-provider-menu\/\">embedded value providers<\/a> cannot be serialized directly as part of <a href=\"https:\/\/docs.unity3d.com\/Manual\/Prefabs.html\">prefab assets<\/a>.<\/p>\n<h1>Solution 1: Create Asset<\/h1>\n<p>You can get around this limitation by adding the <a href=\"https:\/\/docs.unity3d.com\/6000.0\/Documentation\/ScriptReference\/CreateAssetMenuAttribute.html\">[CreateAssetMenu] attribute<\/a> to your value provider, and creating assets to back them.<\/p>\n<p>You can then drag-and-drop the value provider assets into the Init argument fields on your prefab, and they can be serialized.<\/p>\n<h1>Solution 1: Create Sub-Asset<\/h1>\n<p>Another way to bypass the limitation is to the convert the embedded value providers into sub-assets of the prefab asset.<\/p>\n<p>You can do this by right-clicking an embedded value provider on a <strong>prefab instance <\/strong>in the Inspector, and selecting &#8216;<em>Make Sub-Asset of Prefab<\/em>&#8216;.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-562\" src=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/make-sub-asset.png\" alt=\"\" width=\"401\" height=\"293\" srcset=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/make-sub-asset.png 401w, https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/make-sub-asset-300x219.png 300w\" sizes=\"(max-width: 401px) 100vw, 401px\" \/>\u00a0 \u00a0<img loading=\"lazy\" class=\"alignnone size-full wp-image-563\" src=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/sub-asset.png\" alt=\"\" width=\"256\" height=\"79\" \/><\/p>\n<p>You can reverse the process by right-clicking the value provider in the <strong>prefab instance<\/strong> again, and selecting &#8216;<em>Embed Into Prefab Instance<\/em>&#8216;.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-564\" src=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/embed-into-prefab-instance.png\" alt=\"\" width=\"408\" height=\"149\" srcset=\"https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/embed-into-prefab-instance.png 408w, https:\/\/docs.sisus.co\/init-args\/wp-content\/uploads\/sites\/6\/2024\/09\/embed-into-prefab-instance-300x110.png 300w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Issue Due to a limitation with Unity&#8217;s serialization system, embedded value providers cannot be serialized directly as part of prefab assets. Solution 1: Create Asset You can get around this limitation by adding the [CreateAssetMenu] attribute to your value provider, and creating assets to back them. You can then drag-and-drop the value provider assets into ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/docs.sisus.co\/init-args\/problems-and-solutions\/embedded-value-providers-in-prefabs\/\" 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\/580"}],"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=580"}],"version-history":[{"count":7,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/posts\/580\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/media?parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/categories?post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.sisus.co\/init-args\/wp-json\/wp\/v2\/tags?post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}