Cleaning up resource files

Although I have fallen in love with the use of resources, there is something that really bugs me about them. During development I often change the names or formats of variables, or remove them etc. A drawback I see is that the actual file for the resource can become polluted with ‘past’ references that are no longer relevant. And the only way I know of how to clean them up is to manually go through each one, which for an extensive resource or multiple applications (like my terrain resource for all my terrain types) can be a real pain and sometimes very difficult.

Is this something I should just not concern myself with? I understand that it is a good thing that I can change a resource without having to worry about anything already existing being overwritten, that is part of the beauty of using resources of course. So the unused references are inevitable.

But it bugs me that these files can be ‘dirty’. Perhaps as a resource is finalised (say at game completion) it is just a job you have to do, go through and tidy up any polluted resource files, or perhaps it is something I should not be worried about and just ignore.

Anyone got any suggestions or comments about this, what should I do?

A: Not worry about it as it is not important.
B: Just fix it at the end no matter how tedious it might feel.
C: There is something I don’t know that can address this?

When you modify the resource script and add/modify/remove exported properties Godot won’t automatically update the .tres files you already had. You’ll need to re-save the .tres files to update their contents.

But I don’t think you should worry too much about this.

When exporting the project the resources will be converted to binary as long as the project setting Editor -> Export -> Convert text resources to binary is enabled (it’s enabled by default). This will remove any extra old fields from them.

You can also use the Project -> Tools -> Upgrade UIDs... tool to re-save all the scenes/resources at once.

1 Like

@mrcdk Thanks, that is fantastic. I kinda knew this was a silly thing to worry about but it was really bugging me, however not anymore! Thank you.