Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Editing prefab causes references to it to become null until the object referencing it is reloaded

Discussion in 'Prefabs' started by Prodigga, Oct 12, 2018.

  1. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    99
    On the two month anniversary of a fix, is this i 2019 LTS? :)
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Verified in

    Version 2019.3.15f1 (8436a5fe0cd6)
    Sat, 16 May 2020 14:42:44 GMT
     
    a436t4ataf likes this.
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,878
  4. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    @a436t4ataf
    The one you are linking to is a different bug but also caused reference loss.
     
    a436t4ataf likes this.
  5. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    I'm having something similar, I don't know if it's related but: if I try to assign any prefab that has, say, a FooScript to a field of a scritable object of type FooScript, it only accepts the object being dropped if the FooScript component is the first component of the said object.

    If I have the object reference on the said field and if I change the order of the components so the FooScript is no longer the first, the reference to it is lost and I cannot reassign the object on that field.

    That's pretty frustrating because this way I cannot reference the same prefab that has lots of different components on it to different fields that references different types.

    Btw: I'm on 2019.4.12f1

    Edit: A workaround is to lock the object that will store the reference, select your prefab and drag only the component you want to reference.
     
    xjjon likes this.
  6. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    596
    Yeah I know what you are talking about. The pop up selector does not have any choice. Only if you set it as `GameObject` did it work. I don't believe this is supposed to be this way.

    It's a different issue than this thread though.
     
  7. DigitalSalmon

    DigitalSalmon

    Joined:
    Jul 29, 2013
    Posts:
    99
    To be honest this thread wasn't about one specific issue/bug, it was about the fact prefab references get lost, generally speaking. It'd be tidy to keep seperate issues seperate, but even if it's technically a different bug, it still speaks to the fact that Unity prefabs are still unreliable.
     
  8. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    I ran into one just a few days ago where references to child objects inside a prefab were lost as soon as that prefab was instantiated. Putting them back manually works, until you "Apply" them to the prefab at which point they're lost again immediately. They show up as "None" when in the scene, but with their correct values when in prefab view.

    Happens consistently on a random handful of objects, 2020.1.2.
     
  9. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    Yep, that too, but in my case I'm not being able to drag (from project pane) and drop the said prefab in the object field in the inspector either, only if the first component of the prefab is the same as the object field... that used to work normally. I was kinda used to what you mentioned... which for is an issue as well, but the one I posted is new for me...
     
    futurlab_xbox likes this.
  10. eddietree

    eddietree

    Joined:
    Sep 8, 2014
    Posts:
    38
    Hi @SteenLund, I am experiencing this issue on Unity 2020.2.0f1, as well as 2020.1.8f1

    Essentially what is going on is in a ScriptableObject I have references to a Prefab's Monobehavior (not the GameObject itself). When trying to reference the ScriptableObject's value, I get NULL even though the value is clearly there. Reopenning Unity oddly fixes all the null references it but is really buggy behavior.
     
    Last edited: Dec 16, 2020
    futurlab_xbox likes this.
  11. eddietree

    eddietree

    Joined:
    Sep 8, 2014
    Posts:
    38
    Hi @SteenLund - just following up on the prev message, I submitted a bug w/ a super simple repro case to Unity with steps on how to get reproduce the bug 100% every time.

    Attached repro Unity Project case here (Unity 2020.2.0f1).

    Steps on how to repro:
    This bug occurs on Unity versions 2020.2 and 2020.1

    I made a video on how to repro it step-by-step:


    Please help us, thank you!
     

    Attached Files:

    Last edited: Dec 18, 2020
  12. eddietree

    eddietree

    Joined:
    Sep 8, 2014
    Posts:
    38
    futurlab_xbox likes this.
  13. eddietree

    eddietree

    Joined:
    Sep 8, 2014
    Posts:
    38
    Any updates on this? Extremely annoying to deal with this, would love to find a way to solve this, thanks.
     
    futurlab_xbox likes this.
  14. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    596
    It stopped happening to me after changing the assets to be addressables. Not really a fix, but that is why I stopped having to deal with the old problem
     
    futurlab_xbox likes this.
  15. sherif_unity910

    sherif_unity910

    Joined:
    Aug 3, 2022
    Posts:
    3
    This just happened to me today on 2023.1.3f1. I edited a prefab at the lowest level, and suddenly all objects in all scenes with components that have that prefab assigned to a field have lost their references to that prefab. They show "Missing", and this lead to quite some nasty hidden issues and errors.

    I am on MacOS M1.
     
  16. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    804
    Getting the error still in 2020.3.48f1 LTS.