Godot version:
Godot 3.1 8b77dca
Issue description:
It is frustrating to have to manually save a resource every time I edit a property from the Inspector. I would rather the process be automated some way so that I don't forget to save it or have to go back to the resource if I move away from it just to save it before returning to where I was.
Right now when if you open a resource and edit it... and then open another resource and edit it too.
Even though the values were saved.. they are not! They only save when you click the save button (icon) when in the inspector.
Steps to reproduce:
Having two resources:
1) Edit the first
2) Double click the other resource
3) Edit the second resource
4) Double click the first (the values seem to be saved)
5) Close and Reopen the project
6) Values were not saved
Possible solution:
Add toggleable editor settings that do the following...
Save a resource every time its properties are edited. If the properties are set through an EditorPlugin (like for embedded curve editors), then serialize the data on a loop while editing (or something to just no execute I/O operations per frame while changing data every frame).
Additionally, auto-save a resource when switching from that resource to a different one. This would be accomplished with very little changes in the editor.
So, recently I noticed the resources do actually autosave. Not sure how (might be something with saving project i.e. CTRL+S or auto-save on run), but I could e.g. create and edit tileset with tileset editor without even touching the save resource button.
So, recently I noticed the resources do actually autosave. Not sure how (might be something with saving project i.e. CTRL+S or auto-save on run), but I could e.g. create and edit tileset with tileset editor without even touching the save resource button.
it only autosaves on run!! CTRL+S will not save...
create your own resource a custom one...
a class deriving from resource
extends Resource
class_name MyResourceType
export(String) var name
create a bunch of these resource, edit them... and try to do CTRL+S and restart the editor.
The resources will not save.
Maybe can have signals used in this change? It might make more sense an allow for much more extended behaviour instead of only auto-saving (see https://github.com/godotengine/godot/issues/16365).
Maybe this is also related to https://github.com/godotengine/godot/issues/6201? I'm guessing if we have a check for detecting inspector value changes it would be straightforward to implement a record mode for keyframing.
Maybe this is also related to #6201? I'm guessing if we have a check for detecting inspector value changes it would be straightforward to implement a record mode for keyframing.
Don't know how it is related, and don't think it is! This patch intent is automatically saving resource files so you don't lose your work! It happens to me a lot to just open the editor, create some Items/Weapons (that in my game are Resource extending classes) I save the project close and then I realize the changes didn't save!!
Maybe can have signals used in this change? It might make more sense an allow for much more extended behaviour instead of only auto-saving (see #16365).
Using signals for this (automatically saving resource files so you don't lose your work) raises a problem.. imagine you are updating a number with a scroll (or up-down) every time you change the value the resource would be saved to the disk.. and that would not be a good implementation.
I think signal on export property change would be a good addition to Godot in the future but not for this purpose.
By default, Ctrl+S saves the current scene (and running saves them all), which also saves all resources referenced by it. In many cases that means Godot will save work related to those scenes kind of automatically, but if you created a resource which is not referenced it may indeed not be included in that autosaving (see https://github.com/godotengine/godot/issues/25832#issuecomment-465606691). I'd prefer have the option not to save resources everytime they are edited though, I'm of the ones who want to have control of when to write work to disk and when not to :p (that includes shaders and scripts).
Also my hard-drive has some slownesses, I would not want to hammer it while editing resources ;)
But I do agree that Godot does not warn you when you have edited, unsaved resources open, as it only checks for scripts and scenes and can easily be forgotten. Would be nice if Godot could even show a list of reources it has unsaved before closing (including those still in the history, which you can get back to using the "previous edited" button, which I sometimes use in case of misclick).
@Zylann the PR I proposed allows for enable and disable this auto save functionality... I know it would be ideal to also have a notification alerting to unsaved resources! But that would make the PR more complex and not a pick for the 3.1 release. But it for sure should be considered for future implementations.
Right now the idea was to provide a simple way to resolve the lose of work/time I鈥檝e been experiencing the last 6 months I鈥檝e been using Godot!
In Godot 3.1, I changed Godot to save every edited resource when you run or ctrl-s, no matter whether its used or not by the current scene. If this is not working, please open a different issue.
I see that if there is a resource that is used by one that is saved to disk (like a gradient texture) this does not make the parent resource to be saved. This can be fixed, though, so please open a new issue about this.
Is there still a need for this proposal after 9ca6ffa3?
Most helpful comment
@Zylann the PR I proposed allows for enable and disable this auto save functionality... I know it would be ideal to also have a notification alerting to unsaved resources! But that would make the PR more complex and not a pick for the 3.1 release. But it for sure should be considered for future implementations.
Right now the idea was to provide a simple way to resolve the lose of work/time I鈥檝e been experiencing the last 6 months I鈥檝e been using Godot!