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
- Asset creation in the Project Browser is not always undone/inconsistent when the undo shortcut is pressed right after creating an asset
- JobTempAlloc memory leak warning is thrown when the Player is shut down
- Graphics State Collection warm-up does not work when using with Addressables Shaders
- "Baked Shadow Radius" field is visible but inactive when when the Shadow Type is set to "Hard Shadows" under the Light Component
- Crash on OnDemandScheduler::HandleImportWorkerLogs when performing various Unity operations
Add comment