Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Storing Prefab properties in a scene and applying them to prefab instantiated via Addressables

Discussion in 'Prefabs' started by LinkoVitch, Nov 15, 2020.

  1. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    16
    Hi,
    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.
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    There's no runtime Prefab override functionality. I'm not very well familiar with addressables, but at least in the Prefab system itself there's no functionality to do what you're talking about. You'd have to find your own way.
     
  3. LinkoVitch

    LinkoVitch

    Joined:
    May 14, 2015
    Posts:
    16
    Thanks for confirming. I have implemented separate factory/proxy classes, for those that need something a little more than just position information.