summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--editor/editor_node.cpp16
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/script_create_dialog.cpp1
-rw-r--r--editor/shader_create_dialog.cpp3
4 files changed, 21 insertions, 0 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f8e23ecc9d..0df062c508 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1454,6 +1454,16 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
file->popup_file_dialog();
}
+void EditorNode::ensure_uid_file(const String &p_new_resource_path) {
+ if (ResourceLoader::exists(p_new_resource_path) && !ResourceLoader::has_custom_uid_support(p_new_resource_path) && !FileAccess::exists(p_new_resource_path + ".uid")) {
+ Ref<FileAccess> f = FileAccess::open(p_new_resource_path + ".uid", FileAccess::WRITE);
+ if (f.is_valid()) {
+ const ResourceUID::ID id = ResourceUID::get_singleton()->create_id();
+ f->store_line(ResourceUID::get_singleton()->id_to_text(id));
+ }
+ }
+}
+
void EditorNode::_menu_option(int p_option) {
_menu_option_confirm(p_option, false);
}
@@ -2173,6 +2183,12 @@ void EditorNode::_dialog_action(String p_file) {
case RESOURCE_SAVE_AS: {
ERR_FAIL_COND(saving_resource.is_null());
save_resource_in_path(saving_resource, p_file);
+
+ if (current_menu_option == RESOURCE_SAVE_AS) {
+ // Create .uid file when making new Resource.
+ ensure_uid_file(p_file);
+ }
+
saving_resource = Ref<Resource>();
ObjectID current_id = editor_history.get_current();
Object *current_obj = current_id.is_valid() ? ObjectDB::get_instance(current_id) : nullptr;
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 49c1699c28..4a283983c8 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -747,6 +747,7 @@ public:
void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
void save_resource(const Ref<Resource> &p_resource);
void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
+ void ensure_uid_file(const String &p_new_resource_path);
void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 8dd2fe8e4e..d38ff7af76 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -359,6 +359,7 @@ void ScriptCreateDialog::_create_new() {
alert->popup_centered();
return;
}
+ EditorNode::get_singleton()->ensure_uid_file(lpath);
}
emit_signal(SNAME("script_created"), scr);
diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp
index 2bfe088e7f..e1c797633a 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -31,6 +31,7 @@
#include "shader_create_dialog.h"
#include "core/config/project_settings.h"
+#include "editor/editor_node.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/gui/editor_validation_panel.h"
#include "editor/themes/editor_scale.h"
@@ -240,6 +241,7 @@ void fog() {
alert->popup_centered();
return;
}
+ EditorNode::get_singleton()->ensure_uid_file(lpath);
emit_signal(SNAME("shader_include_created"), shader_inc);
} else {
@@ -258,6 +260,7 @@ void fog() {
alert->popup_centered();
return;
}
+ EditorNode::get_singleton()->ensure_uid_file(lpath);
}
emit_signal(SNAME("shader_created"), shader);