Search Issue Tracker
Duplicate
Votes
1
Found in
5.2.3f1
Issue ID
748304
Regression
No
Default integer values is 0 in arrays of serializable classes even if in the script is set otherwise
To reproduce:
1. Open attached project
2. Open "Main" scene
3. Select "SerializedDefaultsTest" game object in the Hierarchy
4. In the Inspector set "Foos" array size to 1
5. Notice that "Bar" value is 0
6. Open "SerializedDefaultsTest.cs" script
7. Notice that default "Bar" value in script is set to 1, not 0
Expected behavior: "Bar" value should be 1
Actual behavior: "Bar" value is 0
Comments (1)
-
Sycobob
Feb 21, 2016 01:59
This applies to *all* serialized fields of any type. When in an array, field initializers and values set in the constructor are ignored and all fields are set to default values for their types. Contrast this with serialized fields in objects that are no in collections where field initializers and constructors are respected. This destroy the ability to provide coherent default values to designers for objects that will be used in collections.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Shader Graph Swizzle Node Input/Output and Mask Update Incorrectly After Undo
- [URP] Crash on GameObject::QueryComponentByType when baking a Reflection Probe in an unsaved/untitled Scene
- No Icons are used for the Entry and Exit States in the Inspector when selected in an Animator Controller
- Crash on PlayerMain(int, char const**) when exiting Standalone Player with a Particle System in the Scene
- No Icon is used for the Runtime Animator Controller Type in a Search Window when assigning an Animator Controller in the Animator Component
This is a duplicate of issue #768959