Merge pull request #16893 from GodotExplorer/debugger-improvement-3

Save runtime node as scene from remote scene tree.
This commit is contained in:
Juan Linietsky 2018-05-07 16:41:34 -03:00 committed by GitHub
commit 80b9edf0f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 1 deletions

View file

@ -37,6 +37,7 @@
#include "os/os.h"
#include "project_settings.h"
#include "scene/main/node.h"
#include "scene/resources/packed_scene.h"
void ScriptDebuggerRemote::_send_video_memory() {
@ -148,6 +149,16 @@ void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_
}
}
void ScriptDebuggerRemote::_save_node(ObjectID id, const String &p_path) {
Node *node = Object::cast_to<Node>(ObjectDB::get_instance(id));
ERR_FAIL_COND(!node);
Ref<PackedScene> ps = memnew(PackedScene);
ps->pack(node);
ResourceSaver::save(p_path, ps);
}
void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) {
//this function is called when there is a debugger break (bug on script)
@ -322,6 +333,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
else
remove_breakpoint(cmd[2], cmd[1]);
} else if (command == "save_node") {
_save_node(cmd[1], cmd[2]);
} else {
_parse_live_edit(cmd);
}