Search Issue Tracker

Duplicate

Votes

0

Found in

2020.2.0a17

Issue ID

1265108

Regression

No

Reordering elements of a list with [SerializeReference] in the UI swaps data but not type

Serialization

-

Context:
I have a script that contains a list of serializable classes following this structure:

[Serializable]
class Test
{
public string name;

public Test()
{
name = "Test";
}
}

[Serializable]
class Test1 : Test
{
public string different1;
public Object sameName;

public Test1()
{
different1 = R.integer.ToString();
name = "Test 1";
}
}

[Serializable]
class Test2 : Test
{
public string different2;
public Object sameName;

public Test2()
{
different2 = R.integer.ToString();
name = "Test 2";
}
}

When the class type Test 1 and Test 2 are created, their name is set to "Test 1" and "Test 2" respectively, also note that the class Test1 has a property "different1" and Test2 has "different2". This means that it is impossible in the UI to have for example Test1 with the property "different 2" and vice versa.

Repro steps:
- Open the repo project
- Open the SampleScene scene
- Select the "List" GameObject, the list should be empty
- Enter in play mode, this will fill the list with random values
- Reorder some element in the list and look at the property name "Different 1" and "Different 2"
- Observe that all the data is moved correctly except the properties Different 1 and Different 2.

What I think is happening:
I think the data of the object is swapped but not its type which explains why the "different 1" and "different 2" properties can't be re-ordered but the rest of the values are re-ordered when we move an element from place x to y.

Alternatively, you can put the script TestList.cs in an already existing unity project to repro

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.