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
- Disabled assets in Import Unity Package window aren't tracked but count as being selected by user
- [Windows] Crash on GetManagerFromContext when video is playing and creating High Definition 3D Projects after FMOD failed to switch back to normal output Error appeared
- GC Alloc produced when adding items to MultiColumnListView with Auto Assign Binding
- Mouse and Pointer Events are called incorrectly in ScrollView with XRUIInputModule
- Memory leak occurs when repeatedly minimizing and maximizing the UI Builder window
Add comment