-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Fix typed arrays not saving properly #82976
Conversation
From what I can see GDScript also uses godot/modules/gdscript/gdscript_parser.cpp Lines 4145 to 4147 in 6916349
And changing the I'm not entirely sure what |
Huh! That's certainly strange, but can't argue with the fact the live version works Regardless of if there's a difference in serialization of a typed vs untyped array, I imagine it'd be convenient if resources saved uniformly. So if this hint string was required in the first place, then it must mean the actual serialization utilizes some other means to tell if an array is typed or not. This method takes effect for GDScript, but not CSharp |
So I tested exported typed arrays in Godot v4.1.2.stable.mono.official.399c9dc39, and this is how the scene is serialized: [gd_scene load_steps=3 format=3 uid="uid://b4e5y5y8e3b15"]
[ext_resource type="Script" path="res://MyNode.cs" id="1_ja7li"]
[ext_resource type="Script" path="res://MyNode.gd" id="2_n82wm"]
[node name="Main" type="Node"]
[node name="MyNodeCS" type="Node" parent="."]
script = ExtResource("1_ja7li")
NumberArray = Array[int]([1, 2, 3])
[node name="MyNodeGD" type="Node" parent="."]
script = ExtResource("2_n82wm")
number_array = Array[int]([1, 2, 3]) So it seems it's already using the typed array for serialization in both C# and GDScript. How did you get it to serialize using the untyped array? What version of Godot were you using? |
Huh… I'm not sure what happened then. The dev build I was testing on had this bug, but that's not the case for 4.1.2 nor the recent 4.2 beta3. I'll have to do some digging to see what happened |
As this doesn't seem to represent the live nor upcoming godot versions, I'll be closing this PR. If I find a consistent means of replication, I'll make a new PR with whatever new context came up |
Fixes a typo in
ScriptPropertiesGenerator.cs
that was making the passed hintTypeString
instead ofArrayType
. While I'm not certain of the full ramifications of fixing this error, one immediate benefit is having resources correctly save arrays as typed if they're exported as such (like GDScript)Example file to save a single "
123
" entryBefore:
After: