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
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- Crash with “Fatal Error! The file ‘MemoryStream’ is corrupted!” when adding a large number in Font Character Rects Size field
This is a duplicate of issue #768959