Search Unity

Unity 5.6 changing a prefab during runtime?

Discussion in 'Prefabs' started by tawdry, Jan 30, 2019.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Hello
    I have a prefab made up of many objects some can be interacted with others are static but once a player has interacted removed a object from the prefab how do I update the prefab to reflect this. When the player leaves the area i destroy the prefab but load it from resources file if he returns so the prefab must have changed else it would be as if the player never interacted with it before.
    Any idea best way to do this
    Thx
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Prefabs don't exist at runtime, only GameObjects baked out from Prefabs. You can't have runtime code make changes to Prefabs. This applies both to Unity 2018.3 and above, as well as earlier versions like Unity 5.6.
     
  3. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Resource files in a game build can't be edited.

    You will need to devise a system yourself for maintaining dynamic data.
     
  4. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Hmm so is there a way to access these baked out GameObjects at runtime? Or would I have to just have objects that wont change in the prefab and the dynamic parts kept as individual gameobjects?