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

Saved resources will preserve default exported variable values #80894

Open
stryker313 opened this issue Aug 22, 2023 · 5 comments · May be fixed by #80897
Open

Saved resources will preserve default exported variable values #80894

stryker313 opened this issue Aug 22, 2023 · 5 comments · May be fixed by #80897

Comments

@stryker313
Copy link

Godot version

3.6 beta 2

System information

Windows 10 gtx 1060 6gb intel i5 4690k

Issue description

When you save a custom resource with exported vars, it will write the default value to the .tres file

Screenshot 2023-08-22 09-40-31

Comparing to the Animation class
Screenshot 2023-08-22 09-45-46

Only when you set a new value is that value written to file...

This also happens when you extend a Godot class, ie extends Animation, all new properties will have their default values written, but all the original ones belonging to the parent class will still function normally...

This adds a size + loading penalty for adding export vars.

Steps to reproduce

  1. Create a new custom resource
  2. Give the custom resource several exported vars
  3. Change none of their values
  4. Give a class name to the resource
  5. Save the resource using ResourceSaver.save(), and save as a .tres
  6. Open the file in a text editor, and you will see that the default values are written to file.

Minimal reproduction project

PropertySize.zip

@dalexeev
Copy link
Member

MRP for 4.x: PropertySize.zip.

@Calinou
Copy link
Member

Calinou commented Aug 22, 2023

We may want to add an annotation to control this behavior (with the default being "don't save"), as it can be desired in some cases. This needs more core changes though, so it can be left for later.

@dalexeev
Copy link
Member

dalexeev commented Aug 22, 2023

We may want to add an annotation to control this behavior (with the default being "don't save"), as it can be desired in some cases.

Yes, I suggested something like that (godotengine/godot-proposals#2581 (comment)). For example, theme property overrides have a checkbox - if you check it, the value will be saved always. And also when inheriting scenes you can "pin" property (#52943).

But I think this applies to all properties, both custom and standard. In my opinion this is definitely a bug, because it is inconsistent with the standard resource properties and any node properties: they are not saved in the file if they are default.

@stryker313
Copy link
Author

#80897
4.x only?

@dalexeev
Copy link
Member

4.x only?

PRs should first be opened against the master branch (if the bug is in master). Then the fix can be cherry-picked or reimplemented for older supported branches, if it's considered desirable and safe enough.

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

Successfully merging a pull request may close this issue.

3 participants