Skip to content
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# Export members no more initialized #54414

Closed
ZwieBit opened this issue Oct 30, 2021 · 7 comments · Fixed by #54423
Closed

C# Export members no more initialized #54414

ZwieBit opened this issue Oct 30, 2021 · 7 comments · Fixed by #54423

Comments

@ZwieBit
Copy link

ZwieBit commented Oct 30, 2021

Godot version

3.4 RC2 / Mono

System information

Windows 11, Intel 655

Issue description

Opening my existing project in the editor shows all variables initialized.

variables1

Starting the project gives me errors because they are actually set to zero.

Upon closing and opening the scene all variables are actually set to zero.

variables2

Even assigning new values and saving the scene has no effect.

Maybe this is related to
#54199 ? (Keep order of c# export members)

Steps to reproduce

Having a RC1 Project with export members, open the scene and run it - everything is not initialized. In RC1 everything works fine but variables are displayed unordered:

image

Minimal reproduction project

No response

@raulsntos
Copy link
Member

I can't reproduce this issue, can you upload a minimal reproduction project?

This could be related to #37812 and/or #51626 but both of those issues already existed before 3.4 RC2. Are you sure you couldn't reproduce it in RC1? The PR you mentioned shouldn't be causing this issue and don't see any commits between RC1 and RC2 that could be causing this.

@ZwieBit
Copy link
Author

ZwieBit commented Oct 30, 2021

I'll try to create a minimal project. Currently i'm working with RC1 without any issues and as soon as i switch to RC2 it's not.

@ZwieBit
Copy link
Author

ZwieBit commented Oct 30, 2021

ExportTest.zip

Actually it seems related to [Tool] - When i open the project with RC1 i can change the variable and it is reflected by a program start (GD Print Output). If i open it with RC2 i can change it, but it will stay to 0.

@raulsntos
Copy link
Member

raulsntos commented Oct 30, 2021

I can reproduce this with 3.4 beta 6 so I think your issue is not specific to RC2, what I also noticed is your scene looks like this:

[gd_scene load_steps=2 format=2]

[ext_resource path="res://SpatialTest.cs" type="Script" id=1]

[node name="Spatial" type="Spatial"]
SomeVariable = 4
script = ExtResource( 1 )

When opening the scene in Godot, SomeVariable value is 0 but if you move SomeVariable below the script like this:

[gd_scene load_steps=2 format=2]

[ext_resource path="res://SpatialTest.cs" type="Script" id=1]

[node name="Spatial" type="Spatial"]
script = ExtResource( 1 )
SomeVariable = 4

Then it seems to work fine, so I guess the problem is due to the order in which the scene is deserialized. I don't know how the scene ended up being serialized in that order though. Okay saving the scene always puts the variable before the script in RC1 and below the script in beta 6 so I guess that's why.

And now that the issue seems to be caused by the order of the variables in the scene I can see how the PR you mentioned might have caused this issue.

@ZwieBit
Copy link
Author

ZwieBit commented Oct 30, 2021

After removing [Tool] it also works fine in my main project in RC2 after reassigning the variables. Reopening / Closing the project works flawless then - But in the upgrade process they broke.

Adding [Tool] again, they are all zero again at launch of my game and after saving.

@Chaosus
Copy link
Member

Chaosus commented Oct 30, 2021

Adding [Tool] again, they are all zero again at launch of my game and after saving.

It's a duplicate of #37812 then and should be closed

@raulsntos
Copy link
Member

raulsntos commented Oct 30, 2021

@Chaosus I don't think so since this is caused by different reasons.

This issue is caused by the script variables being serialized before the script property (causing them to be ignored on deserialization). It only affects Tool scripts because of how the loading of their properties values is handled by the editor.

#37812 seems to be caused by assembly reloading not being able to keep the values of Tool script properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants