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
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
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Active Targets section text in Graph Inspector is truncated despite available space
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
- Shader Graph Node information is briefly displayed in Graph Inspector when clicking on Category in the Blackboard
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
Add comment