Search Unity

Prefab Mode Breaks References to Prefabs in Project Folder

Discussion in 'Prefabs' started by owen_proto, Dec 29, 2018.

  1. owen_proto

    owen_proto

    Joined:
    Mar 18, 2018
    Posts:
    118
    I wrote a system to replace tags that is pretty simple - scriptable objects behave as "groups" and consist essentially of just a list. A script resides on a game object that keeps track of which "groups" that object belongs to and adds itself to the list in each of those groups (scriptable objects).

    In 2018.2 I was able to add the script that goes on each object to prefabs directly in the inspector with a prefab selected in the project folder. In 2018.3 this is also done in the inspector, but in prefab mode. In 2018.2 the references to prefabs residing in the project folder from the lists residing in the scriptable objects persisted without a problem. In 2018.3, when exiting prefab mode, I can see that the changes I'm making are indeed being saved (I wrote a custom editor and eventually found Undo.RegisterCompleteObjectUndo and PrefabUtility.RecordPrefabInstancePropertyModifications) but the reference in the scriptable object list is broken as if the prefab was deleted. It's as if I'm not editing the prefab directly, but a temporary instance of it.

    It seems I can easily get around this by keeping a copy of every prefab in the scene. Is this a recommended workflow? It seems counter to the intention of prefab mode. Any guidance is appreciated.
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    @OldLegWig

    This sounds very much like a known bug that has just been fixed, but just to make sure could you please file a bug report with attached scripts and steps to reproduce.
     
  3. Jay-Pavlina

    Jay-Pavlina

    Joined:
    Feb 19, 2012
    Posts:
    195
    I am experiencing the same thing in 2018.3.2f1. Anytime I go into prefab mode, all references to that prefab are lost. Pretty crazy bug.

    Edit: Looks like there's another thread about it. And there's already a bug report.
     
    Last edited: Jan 23, 2019
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya I'm seeing what looks like this also in 2018.3.2f1. References to prefabs from scriptable objects going null. but it's not direct editing doing it. It might be indirectly related I haven't been able to track it down yet.
     
    cbrack likes this.