Search Issue Tracker

Fixed in 2018.3.X

Fixed in 2019.1.X

Votes

51

Found in

2018.3.0b1

2018.3.0f2

2019.1.0a1

2019.2.0a1

Issue ID

1116476

Regression

Yes

Prefab's references are lost when modifying prefab

Scene Management

-

How to reproduce:
1. Open attached "PrefabReferenceLostRepro.zip" project
2. Go to Assets -> Scenes and open 'SampleScene'
3. Click on 'Spawner' and call 'Log' in the ContextMenu in the Inspector
4. Observe the Console
5. Go to Assets, open Enemy in Prefab Mode and edit it (e.g. change the position)
6. Repeat 3, 4 steps

Expected result: Console returns 'Enemy(Enemy)'
Actual result: Console returns 'null'

Reproducible: 2018.3.2f1, 2019.1.0a14, 2019.2.0a1
Not reproducible: 2017.3.0a1, 2017.4.18f1, 2018.3.0a11

Fixed in: 2018.3.6f1, 2019.1.0b4, 2019.2.0a6

Comments (46)

  1. 3a3b1af8845f824424b6e7947f4b1530?d=mm

    PJbigscreen

    Feb 18, 2019 12:10

    Same, please fix!

  2. A722dd133c4ac4309a782b2e485822e9?d=mm

    superbcorperation

    Feb 18, 2019 04:04

    This bug still remains on unity 2018.3.5f1

  3. 5128b0daa89af415bb45bfca96007579?d=mm

    K_Seungbeom

    Feb 18, 2019 04:03

    This bug still remains on unity 2018.3.5f1

  4. Cf7f8a0b60950afd0c7810133aeb4ff2?d=mm

    Xtro

    Feb 16, 2019 00:24

  5. Cf7f8a0b60950afd0c7810133aeb4ff2?d=mm

    Xtro

    Feb 15, 2019 21:54

    It looks like this is fixed in 2018.3.6 but actually it's not. I'll send a new bug report.

  6. 72d3cee0e78ddffee03b26d1fe5089ca?d=mm

    Kirbychwan

    Feb 13, 2019 01:19

    Hey, if this isn't fixed can we actually get a fix, guys? Nobody wants to upgrade if it legit breaks everyone's projects. Stuff like this needs to be a top priority.

  7. Eeaa5a8e81c6580d5a2811b9e177d2ec?d=mm

    Mehrdad995

    Feb 06, 2019 16:22

    Hi again,
    The Issue that I mentioned earlier seems a little bit different for me,
    Apparently, I only faced it once I upgraded the project and again Apparently all the meshes that had a similar name where missed,
    i.e. for my road, it's is segmented and in 3Ds Max I named all road meshes for all segments as "road" without any number to distinguish them and most of them are missing.

    p.s. why can't we remove comments? I think my issue is different so I just wanted to remove it.

    thanks for the support btw

  8. Eeaa5a8e81c6580d5a2811b9e177d2ec?d=mm

    Mehrdad995

    Feb 06, 2019 15:11

    This really sucks, it has broken my project which I'm working on for almost 18months
    switched to 2018.2.3f1 and had enough bugs to made me switch to 2019.1.0a14 and I wish I stayed on 2017 version.
    now my gigantic prefab has lost almost all of its mesh components reference and I have to re-assign over 200 meshes, come on :/

  9. 1f4a22b0ec7e38f54d6f378c6b2e3664?d=mm

    edwardrowe

    Feb 06, 2019 14:02

    This also causes an issue with Editing colliders in the Prefab sandbox. When in Edit mode on a collider's component, after you change a vertex on the collider if you have AutoSave enabled it will exit out of Edit mode.

    ProTip - don't use AutoSave in the Prefab Editor.

  10. 04690980e1c9f3f99b6f0c1d2bc03bb7?d=mm

    bjarkeck

    Feb 03, 2019 20:40

    Interesting workaround with the AssetModificationProcessor. Don't know if it's better or worse, but we found out that the AssetDatabase can still tell you things about the object even though it has become "fake null". So here is the solution we used in Odin for anyone interested:

    private static bool ComponentReferenceIsBroken(T component, ref T realInstance)
    {
    var uObj = component;
    var oObj = (object)uObj;

    if (oObj != null && uObj == null) // Checks for fake null.
    {
    // It is safe to get the InstanceId, even though it's fake null.
    var instanceId = uObj.GetInstanceID();

    // The AssetDatabase still knows the broken object, and here it returns true if it's a reference to a prefab.
    // If it returns false, then it could either be destroyed or just "fake null" as serialized unity objects often are.
    if (AssetDatabase.Contains(instanceId))
    {
    // This parts gets the new reference from the prefab.
    var path = AssetDatabase.GetAssetPath(instanceId);
    var realWrapper = AssetDatabase.LoadAllAssetsAtPath(path).FirstOrDefault(n => n.GetInstanceID() == instanceId) as T;
    if (realWrapper)
    {
    // And gives you the new reference.
    realInstance = realWrapper;
    return true;
    }
    }
    }

    return false;
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.