Search Unity

Bug Nested SerializeReference in a prefab will not get imported / refresh

Discussion in 'Scripting' started by bugcamper, Nov 7, 2022.

  1. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    we have a SerializeReference class, within in it another SerializeReference in array form like this:


    class A
    {
    [SerializeReference] class B;
    }

    [Serializable]
    class B
    {
    [SerializeReference] class C[];
    }

    [Serializable]
    class C
    {
    }

    one person added B class to the class A prefab with all the data, and check into plastic source control

    second person, sync up to the change, but they only get the data for first class B SerializeReference, the class C array SerializeReference inside that class remains null.

    as soon as the second person goes to project and right click to reimport that one file, the class C array SerializeReference become the correct data.

    looks like some cache related problem with unity editor.

    we have version 2021.3.12f1
     
    Last edited: Nov 7, 2022
  2. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    Update, this is what very likely what happens, someone syncing to latest change, and the Class C is added as the same changeset prefab is, and unity editor try to import prefab, but can't find class C, it doesn't know about class C yet, and import failed with with error message:

    "Could not update a managed instance value at property path 'managedReferences[xxxxxxxxxxxxxxxx]', with value 'class c'"

    but if user right click the prefab and hit reimport, it import just fine and no error.

    so could be a execution order between prefab update and new classes gets recognized by unity editor.
     
  3. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    so the bug is likely, prefab import happen before code compile, after sycning up plastic
     
  4. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    the problem is made worst by, even though unity editor throw an error when importing the prefab, editor still mark the data imported, restart editor doesn't reimport and fix the problem. so it's very hard for other developer on the team to get around this problem.
     
  5. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    I attached a small project that can reproduce the bug
     

    Attached Files:

  6. HernandoNJ

    HernandoNJ

    Joined:
    May 13, 2018
    Posts:
    75
  7. bugcamper

    bugcamper

    Joined:
    Mar 15, 2022
    Posts:
    11
    this bug is fixed in newer version of 2021.3.xx, forgot which one, but it is fixed