(Case 1368205) Removing entry from Variables Group causes "Could not reach source property" error

Unity 2019.4.2f01, Localization 1.0.1

Reproduce

  • Create “New Variables Group” Asset and select it
  • In the Inspector click the + button and choose “String”
  • Select the newly added string entry and click the - button

Actual
Unity outputs error:
Could not reach source property name ‘m_Variables.Array.data[0]’ while extracting diffs, the reference does not exist in the source serialized data

Expected
No error

1 Like

There’s a reason why they call you QA Jesus :smile:

1 Like

It’s a curse, everything I touch falls apart.

1 Like

This problem still exist on Unity 2021.3.0f1

It’s working fine for me. I just tested the above reproduction steps on 2021.3.0f1 and had no errors.
The original bug was fixed some time ago https://issuetracker.unity3d.com/issues/serializereference-field-from-scriptableobject-loses-value-when-deleting-last-array-item-and-then-pressing-undo

Are you sure this is the same issue you are having? What are the reproduction steps?

Could you please try this on Unity 2020.3.0f1:

using System;
using UnityEngine;

[CreateAssetMenu(fileName = "Repro", menuName = "Test/Create Repro Asset")]
public class Repro : ScriptableObject
{
    public MyClass1[] refs = new MyClass1[]
    {
        new MyClass1()
        {
            srValue = new MyClass2()
        }
    };
}

[Serializable]
public class MyClass1
{
    [SerializeReference]
    public MyClass2 srValue;
}

[Serializable]
public class MyClass2
{
    public int value;
}

8122532--1052864--upload_2022-5-12_21-54-56.gif

This repro can also reproduce another bug:
When click “+” button to add a new list element, the newly added element will reference same object instance with previous element, this should not happen. The bug can be reproduce on Unity 2020.3.0f1 and Unity 2021.3.0f1.
8122550--1052873--upload_2022-5-12_22-4-43.gif

Sorry, earlier I wrote was wrong, it’s Unity 2020.3.0f1, not Unity 2021.3.0f1.
8122553--1052876--upload_2022-5-12_22-7-12.png

Ah yes the fix is not in 2020.3.0f1.
If you look further down the page you will see its in 2020.3.9f1

8122556--1052879--upload_2022-5-12_15-11-1.png

So you need to be on that version or newer.

Thank you!

1 Like

And do you have any relative records about this bug(#7): https://discussions.unity.com/t/856551/7

That’s by design. SerializeReference allows you to reference the same item and pressing + on a list will copy the previous reference, so its working as expected.

But this Act different from general types in a list. And in this case, it makes no sense to use SerializeReferences in the list(all elements in list references same object). Does Unity has any plan to give developer a way to break this reference?

You can control it with a custom editor or through script. We do this in Localization. I’m not aware of any plans to change this behavior at the moment.

Got that, thank you.

1 Like