-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Allow change import type without restarting editor #78890
Conversation
Horray! Can't wait to review this. |
I would go a bit further with this and try to do something with the resource if its in use in the scene. Probably do a logic like this if the resource is actually loaded (ResourceCache can be checked):
IMO this should be good enough for far most cases. |
I think what you described can be done independently, in another PR. It sounds like a lot of work.
All resources in filesystem or all currently loaded? The latter is difficult to determine, because a resource an be held by any random editor plugin. Same with the resource we are replacing. |
@KoBeWi I disagree that it's a lot more work, and I think if this is implemented it should be done properly. Here is some code that walks the whole thing for the edited scene: https://github.com/godotengine/godot/blob/master/editor/editor_node.cpp#L1482 Here is code that walks the cached resources: https://github.com/godotengine/godot/blob/master/editor/editor_node.cpp#L1697 All you have to do here is check if this is an external resource with For PackedScene or SceneState (not active tabs) you may need to implement a function in that class that iterates all the internal properties and replace one if needed, but it should be simple to implement since they are in an array. For editor plugins you can check if the resource is being edited and just clear the editors, or simply for now clear all editors and inspector if that is too much work. Then just clear the undo/redo history and resource clipboard. It is true that it may happen that this resource still remains in use somewhere, but the chance of this happening should be rather low at this point and setting the |
I agree with reduz's reasoning that we don't allow changing import type without doing the proper change as designed earlier. The feature can be broken into several pull requests, but only the final pull request should enable changing types. |
Also on some extra notes:
|
godot.windows.editor.dev.x86_64_0fLg54ySAA.mp4 |
552417d
to
ebdf400
Compare
Ok I completely removed the need to restart. If any used resource changes type, the editor will replace its instances in every opened scene and every cached external resource. I did not implement
You mean I should check |
@KoBeWi Wow you are amazing! For skip_save, my idea is that if for some reason this resource remains somewhere (because of most likely a bug or we did not search exhaustively enough), you set it to the old one (pre replace) with you can check for the metadata and skip it (dont add to resource_set). Then here: If it also has the skip_save metadata, also write OBJECT_EMPTY Likewise same locations for the text saver: and To skip saving it, something like: if (res->get_meta("skip_save",false)) {
return "null";
} else if (internal_resources.has(res)) {
.... |
ebdf400
to
edb5007
Compare
Done. |
Is this something we should cherry pick for 4.0? |
edb5007
to
244968c
Compare
Probably not cherry-pickable, definitely not for 4.0. Can discuss for 4.1 when this gets approved and merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the fixed build error, I did a standard test of switching a scene import to an animation library and no restart was needed.
About using metadata, be aware be aware that scripting might mess with it. Also, would you have it documented? I believe any third party doing some kind of serialization would benefit from learning about it. |
Metadata beginning with |
Thanks! |
When trying to change import type in the Import dock, there is this dreadful popup that you need to restart the editor. The popup exists, because the resource might be used somewhere and changing the type of an existing object is just not possible.
But it doesn't make any sense if the Resource is not used anywhere. So this PR fixes that. When a resource is not loaded anywhere, you can freely change its type. If something uses this resource, you will get a warning that you can ignore. If a resource is currently loaded, the dialog will tell you to close all scenes or restart the editor.
godot.windows.editor.dev.x86_64_7bEfZVxzQx.mp4
EDIT:
Restart is not needed anymore ever. See comments below.