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#] Value of inherited export variable of a 'Tool' resets every recompile #52186

Closed
NadavSch opened this issue Aug 28, 2021 · 2 comments
Closed

Comments

@NadavSch
Copy link

Godot version

Godot_v3.3.3-stable_mono_win64

System information

Windows 10

Issue description

I want to make two C# classes: S1 and S2, and make S2 inherits S1.
S1 has an export variable S1_Int, and S2 has an export variable S2_Int (and also S1_Int that is inherited from S1).

If I add the [Tool] attribute to S1 and S2, an issue arise, when I try to change the value of the export variable S1_Int in S2 (that was inherited from S1) and then compile the C# code, the value of S1_Int resets to the default value.

Example with pictures:
The scene Level.tscn contains S1 and S2:
image

1)At first, S1_Int and S2_Int have their default values (in the example 5 and 20):
image
2)Change S1_Int to 6, and S2_Int to 21:
image
3)Make "Some change" in a cs file to force a recompile:
image
4)Run the project, and notice that S1_Int resets while S2_Int stays with the same value:
image

For some reason, this issue only happens if the scene that contains S1 and S2 is opened, if it's not the value won't reset.
Also, if after the change I close and open Level.tscn again, S1_Int will contain the right value.

Moreover, if I print the values using GD-Print, in the first run the right value will be printed, however in the second run the default value will be printed.

Steps to reproduce

1)Create 2d Project using C# with the mono version.
2)Create 2 scenes, S1 and S2 where S2 inherits S1.
3)Add a protected export variable to S1, and compile the project (in order to view the variable in S2).
4)Change the default value of this variable.
5)Make a small change in the C# code (to force a recompile), and run the project.
6)The value of the inherited variable will reset.

Minimal reproduction project

ToolBugTest.zip

@frankhval
Copy link

I suppose I can confirm that on linux version of 3.3.3. mono x64(kinda, my bug looks like alot like this but is simpler in a way):

After closing and reopening of the project all of the overrided exported variables are "reverted" to default values in the start scene. But closing the scene and opening it again and all the overrided values are intact.

@Chaosus
Copy link
Member

Chaosus commented Oct 30, 2021

Duplicate of #37812

@Chaosus Chaosus marked this as a duplicate of #37812 Oct 30, 2021
@Chaosus Chaosus closed this as completed Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants