0
\$\begingroup\$

I am working on a small script to replace Prefabs in a scene with Addressable versions of the same prefab. This is working so far by creating a second scene with the Prefabs stripped out an a small loader object in their place. When the 2nd scene run the addressables are instantiated and everything is fine.

However, this only works for the absolute base simple case of no changes to the default prefab properties. What I am trying to solve now is storing the current settings of the prefab along with it's addressable reference so that they can be reapplied when it is instantiated.

So far I have looked at PropertyModification to get a list of all the properties and their values, but as this is an Editor only structure it is no good for the instantiation of the objects at runtime. I was thinking I could store the property names and values, but cannot find anyway to then reapply those values back to the newly instantiated object.

Is there any way I can apply (ideally wholesale without the need of custom instantiation scripts) the stored properties to a prefab ?

Thanks in advance.

\$\endgroup\$
  • \$\begingroup\$ The more generic your solution here, the costlier it is likely to be, in implementation effort and runtime performance. Do your prefab changes tend to fit into any specific categories so we could target a lean and fast solution that's limited to serving those categories? \$\endgroup\$ – DMGregory Nov 15 at 11:39
  • \$\begingroup\$ I was hoping to make something "one size fits (mostly) all" but I suspect that isn't going to happen without significant development as you say. I think I may just go the route of a simple basic version that handles transform/flags, and then some custom factories for anything with more flavour as required. \$\endgroup\$ – Graeme Nov 16 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.