mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Reload cached resources in runtime on file reimport
This commit is contained in:
parent
b00e1cbf74
commit
81cb7658f8
@ -1170,6 +1170,12 @@ String ScriptEditorDebugger::get_var_value(const String &p_var) const {
|
||||
return inspector->get_stack_variable(p_var);
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_resources_reimported(const PackedStringArray &p_resources) {
|
||||
Array msg;
|
||||
msg.push_back(p_resources);
|
||||
_put_msg("scene:reload_cached_files", msg);
|
||||
}
|
||||
|
||||
int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) {
|
||||
const int *r = node_path_cache.getptr(p_path);
|
||||
if (r) {
|
||||
@ -1818,6 +1824,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
|
||||
tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed));
|
||||
|
||||
InspectorDock::get_inspector_singleton()->connect("object_id_selected", callable_mp(this, &ScriptEditorDebugger::_remote_object_selected));
|
||||
EditorFileSystem::get_singleton()->connect("resources_reimported", callable_mp(this, &ScriptEditorDebugger::_resources_reimported));
|
||||
|
||||
{ //debugger
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
|
@ -198,6 +198,8 @@ private:
|
||||
void _video_mem_request();
|
||||
void _video_mem_export();
|
||||
|
||||
void _resources_reimported(const PackedStringArray &p_resources);
|
||||
|
||||
int _get_node_path_cache(const NodePath &p_path);
|
||||
|
||||
int _get_res_path_cache(const String &p_path);
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user