Search Unity

Prefab references disappear on instantiate

Discussion in 'Prefabs' started by mccaber, Sep 15, 2018.

  1. mccaber

    mccaber

    Joined:
    Sep 18, 2013
    Posts:
    20
    When I instantiate prefabs that have a script with a reference to another prefab the reference disappears. The references had worked in previous versions. I am using Resources.Load if that matters (something to fix). Any idea how I can get the references to load?
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    We're looking into this issue. In the mean time, could you let us know if selecting the Prefab Asset and selecting "Reimport" fixes the issue?

    Note: Choosing "Reimport All" does not work (also something we're investigating).
     
    duanhong169 likes this.
  3. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    I had experienced something like this. The prefab had references to the other prefabs when I were in prefab editing mode and all that, but lost it when it appeared in the scene. So to fix it, I did it "the old way" by dragging out the prefab into the scene, (and there I noticed the reference was lost) set the prefab as a reference, applied my changes and removed it from the scene. I hope this helps you!
     
  4. mccaber

    mccaber

    Joined:
    Sep 18, 2013
    Posts:
    20
    I ended up with pretty much the same solution. It seems that after upgrading the project the references were maintained in the editor but whatever manifest tells unity what to package for a build forgets that there is a reference until you rebuild/relink it. I manually reset the references so I can't say if the re-import option works but I'm betting it would since reassigning would require the asset be rebuilt again? Sorry I can't give more info. I like the new prefab set up so far though.
     
  5. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Wow, had the same issue in Unity 2018.3.6f1 and I thought the Prefabs from Fungus (narrative plugin) were all broken. Duplicating the prefab or Reimporting them fixed the issue indeed. But it doesn't change any file, so it's not a bug that you can fix on the plugin developer's side by making a commit. I guess it was coming from my local cache?

    Is it possible that the binary to text conversion cause issues when using binary prefabs from the asset store and Forcing them into Text? In this case, the developer could still fix the issue on his own side by resaving the assets as Text after upgrading to Unity 2018.3 (and possibly again as Binary, if that forces to match some new format and changes the final result?)
     
  6. megagon

    megagon

    Joined:
    Jan 7, 2016
    Posts:
    2
    Seem's like we're having the same issue in 2018.4.0f1 on some machines. Any idea what causes it or how to get rid of it?
     
  7. Alebra88

    Alebra88

    Joined:
    Jul 12, 2019
    Posts:
    5
    I have the same problem.

    The only thing I noticed is that if I drag and drop a prefab1 istance into a prefab2 istance, in the inspector the field name is marked with bold characters.

    If I drag and drop prefab1 into prefab2, in the inspector the field name is written with normal characters ( and the references are lost ).
     
  8. clawsofanbear

    clawsofanbear

    Joined:
    Sep 4, 2019
    Posts:
    3
    Reimport worked if I unloaded the scenes that were using the affected prefabs first
     
  9. Deepoo

    Deepoo

    Joined:
    Apr 15, 2021
    Posts:
    4
    @runevision has this issue been resolved ?? i have the same issue. whenever i prefab my game object, the prefab loses its reference in the inspector
     
  10. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    I can't say since I don't work for Unity anymore.
     
  11. XdagDS

    XdagDS

    Joined:
    Dec 15, 2019
    Posts:
    2
    I've had the same problem but I've fixed it.

    The initial object had his own transform position referencing to the world not to an upper empty object transform. Every prefab put on the scene disappered when animation started when really the prefab moved to the initial object.

    I've put the prefab under an empty object and made again the animations, and all the transforms reference to the parent instead to the scene, and now, every prefab I put on the scene, has his own transform and animations are just an offset from de parent and doesn't disappear
     
  12. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Hi, We have made fixes for missing references but to be sure we have fixed the issue any of you are seeing we would appreciate a small repro case in a bug report. Thank you.