summaryrefslogtreecommitdiffstats
path: root/scene/debugger
diff options
context:
space:
mode:
authorMichael Alexsander <michaelalexsander@protonmail.com>2024-10-31 18:17:44 -0300
committerMichael Alexsander <michaelalexsander@protonmail.com>2024-11-05 10:51:20 -0300
commit81cb7658f85dfd382ceb5b3811c162445db068d3 (patch)
tree34ceddde99e8f4e482e0ca77a0c94e2dc69772e5 /scene/debugger
parentb00e1cbf743dcb6a2b7f6bd14e348a1a7cf3d403 (diff)
downloadredot-engine-81cb7658f85dfd382ceb5b3811c162445db068d3.tar.gz
Reload cached resources in runtime on file reimport
Diffstat (limited to 'scene/debugger')
-rw-r--r--scene/debugger/scene_debugger.cpp17
-rw-r--r--scene/debugger/scene_debugger.h1
2 files changed, 15 insertions, 3 deletions
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index b87285ed74..1c05271daa 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -147,7 +147,6 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA);
Transform2D transform = p_args[0];
scene_tree->get_root()->set_canvas_transform_override(transform);
-
runtime_node_select->_queue_selection_update();
#ifndef _3D_DISABLED
@@ -164,16 +163,19 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
scene_tree->get_root()->set_camera_3d_override_orthogonal(size_or_fov, depth_near, depth_far);
}
scene_tree->get_root()->set_camera_3d_override_transform(transform);
-
runtime_node_select->_queue_selection_update();
#endif // _3D_DISABLED
} else if (p_msg == "set_object_property") {
ERR_FAIL_COND_V(p_args.size() < 3, ERR_INVALID_DATA);
_set_object_property(p_args[0], p_args[1], p_args[2]);
-
runtime_node_select->_queue_selection_update();
+ } else if (p_msg == "reload_cached_files") {
+ ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA);
+ PackedStringArray files = p_args[0];
+ reload_cached_files(files);
+
} else if (p_msg.begins_with("live_")) { /// Live Edit
if (p_msg == "live_set_root") {
ERR_FAIL_COND_V(p_args.size() < 2, ERR_INVALID_DATA);
@@ -413,6 +415,15 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
}
}
+void SceneDebugger::reload_cached_files(const PackedStringArray &p_files) {
+ for (const String &file : p_files) {
+ Ref<Resource> res = ResourceCache::get_ref(file);
+ if (res.is_valid()) {
+ res->reload_from_file();
+ }
+ }
+}
+
/// SceneDebuggerObject
SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) {
id = ObjectID();
diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h
index f9dd6161aa..9e9f61aac5 100644
--- a/scene/debugger/scene_debugger.h
+++ b/scene/debugger/scene_debugger.h
@@ -67,6 +67,7 @@ public:
static Error parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured);
static void add_to_cache(const String &p_filename, Node *p_node);
static void remove_from_cache(const String &p_filename, Node *p_node);
+ static void reload_cached_files(const PackedStringArray &p_files);
#endif
};