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
- "Customize handled extensions" part in the External Tools settings tab is not aligned with other properties
- Editor Diagnostics foldouts do not open when clicked on the foldout title
- [UI Builder] Visual Elements are not placed at the mouse cursor position when Absolute Position Placement is enabled
- "Width" and "Height" text is misaligned with slider ends in Screen Match Mode Parameters section of Panel Settings Asset
- Editor does not quit when Editor is not in focus and any floating window is opened
Add comment