Search Unity

Bug Reference to Nested prefabs lost in objects 100% repro until nuking libraries.

Discussion in 'Editor & General Support' started by hoesterey, Jun 6, 2020.

  1. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Hi,
    Unity version 2019.3.6f1

    I had a 100% repro for this but sadly/happily nuking libraries fixed the problem. We are still getting all sort of odd issues when building though that seams related where serialized references are turning up null in xbox builds. Sadly every build is different (without code changes) and most the time they work.

    Here is the repro I had.
    Nested Prefab 1 Hierarchy
    proj_player_cannonSecondary_t3_pf Variant ->proj_player_cannon_t1_pf Variant ->proj_player_base_pf

    Nested Prefab 2 Hierarchy
    proj_player_cannonSecondary_t2_pf Variant ->proj_player_cannonSecondary_t3_pf Variant ->proj_player_cannon_t1_pf Variant ->proj_player_base_pf

    These prefabs are referenced by the projectile fields of the following scriptable assets:
    weaponRangedPlayer_Secondary_Cannon_T2
    weaponRangedPlayer_Secondary_Cannon_T3


    Repro we had for breaking the references to the nested prefabs:

    select the following (don't OPEN any prefab just change it in project folder)

    proj_player_cannonSecondary_t2_pf Variant

    change the Damage and AOE damage fields

    now select
    proj_player_cannonSecondary_t3_pf Variant change the damage and AOE damage

    now select weaponRangedPlayer_Secondary_Cannon_T2 notice projectile field is empty! It lost reference to those prefabs!!!! It will never come back and should someone check it in by accident the project becomes very broke.

    The above type of thing happens ALOT and randomly. I think I know why this may have happened in editor but its hard to know when and how it happens. The above was the first 100% I had and then it went away when nuking libraries. I think what is happening is Unity is saving the inherited asset behind the scenes while you edit the child and this causes all sorts of chaos when the child tries to save.


    I think the above is the issue because you can get a null error at runtime with ANY high load project (big project) by doing the following:
    • Edit a nested prefab with "Auto Save" on.
    • Quickly press play in editor while the asset is saving.
    • All references to the saving nested prefab will be lost at runtime and you'll get a lovely amount of null errors.