Search Issue Tracker
Fixed in 2017.3.0f3
Fixed in 2017.2.X
Votes
0
Found in
5.6.0f3
Issue ID
918102
Regression
No
[.NET] const field named same as a field in base class causes the field in base class to not get serialized
Repro consists of 2 classes:
using UnityEngine;
abstract class BaseClass : MonoBehaviour
{
[SerializeField]
private int m_Number = 5;
public void LogNumber()
{
Debug.Log(m_Number);
}
}
class DerivedClass : BaseClass
{
private const int m_Number = 56;
private void Awake()
{
Debug.Log(m_Number);
LogNumber();
}
}
Drag DerivedClass onto main camera, and set "m_Number" field to 22 in the inspector. Hit play in the editor and observe the following output:
56
22
Now, build to Windows Store .NET scripting backend. Run it, and observe this output:
A script behaviour (probably DerivedClass?) has a different serialization layout when loading. (Read 32 bytes but expected 36 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
(Filename: D:\Projects\unity\Runtime/Serialize/SerializedFile.cpp Line: 1895)
56
5
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- ComputeBuffer readback fails when Render Graph is enabled
- Opening Terrain Prefab in Prefab Editing Mode throws "NullReferenceException" error
- [Search] Dragging query pills put them behind the search text field
- A CustomPropertyDrawer that returns a PropertyField for a property named the same as a child field will not render all child fields
- Graphics Settings shows default values instead of the real values in the Rendering Debugger when Volume.profile is assigned via script
Add comment