Skip to content

Commit ba19a70

Browse files
committed
XR Editor: Proof-of-concept immersive editing using the debugger
1 parent 7864ac8 commit ba19a70

File tree

7 files changed

+564
-1
lines changed

7 files changed

+564
-1
lines changed

editor/debugger/script_editor_debugger.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "editor/editor_log.h"
4545
#include "editor/editor_node.h"
4646
#include "editor/editor_string_names.h"
47+
#include "editor/editor_undo_redo_manager.h"
4748
#include "editor/file_system/editor_file_system.h"
4849
#include "editor/gui/editor_file_dialog.h"
4950
#include "editor/gui/editor_toaster.h"
@@ -449,6 +450,38 @@ void ScriptEditorDebugger::_msg_scene_inspect_object(uint64_t p_thread_id, const
449450
}
450451
#endif // DISABLE_DEPRECATED
451452

453+
void ScriptEditorDebugger::_msg_scene_select_path(uint64_t p_thread_id, const Array &p_data) {
454+
ERR_FAIL_COND(p_data.is_empty());
455+
String scene_path = p_data[0];
456+
String node_path = p_data[1];
457+
if (EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path() == scene_path) {
458+
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node_or_null(node_path);
459+
if (n) {
460+
EditorSelection *selection = EditorNode::get_singleton()->get_editor_selection();
461+
selection->clear();
462+
selection->add_node(n);
463+
}
464+
}
465+
}
466+
467+
void ScriptEditorDebugger::_msg_scene_set_object_property(uint64_t p_thread_id, const Array &p_data) {
468+
ERR_FAIL_COND(p_data.is_empty());
469+
String scene_path = p_data[0];
470+
String node_path = p_data[1];
471+
String property_path = p_data[2];
472+
Variant value = p_data[3];
473+
if (EditorNode::get_singleton()->get_edited_scene()->get_scene_file_path() == scene_path) {
474+
Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node_or_null(node_path);
475+
if (n) {
476+
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
477+
undo_redo->create_action("Update property remotely");
478+
undo_redo->add_do_property(n, property_path, value);
479+
undo_redo->add_undo_property(n, property_path, n->get(property_path));
480+
undo_redo->commit_action();
481+
}
482+
}
483+
}
484+
452485
void ScriptEditorDebugger::_msg_scene_debug_mute_audio(uint64_t p_thread_id, const Array &p_data) {
453486
ERR_FAIL_COND(p_data.is_empty());
454487
// This is handled by SceneDebugger, we need to ignore here to not show a warning.
@@ -974,6 +1007,8 @@ void ScriptEditorDebugger::_init_parse_message_handlers() {
9741007
#ifndef DISABLE_DEPRECATED
9751008
parse_message_handlers["scene:inspect_object"] = &ScriptEditorDebugger::_msg_scene_inspect_object;
9761009
#endif // DISABLE_DEPRECATED
1010+
parse_message_handlers["scene:select_path"] = &ScriptEditorDebugger::_msg_scene_select_path;
1011+
parse_message_handlers["scene:set_object_property"] = &ScriptEditorDebugger::_msg_scene_set_object_property;
9771012
parse_message_handlers["scene:debug_mute_audio"] = &ScriptEditorDebugger::_msg_scene_debug_mute_audio;
9781013
parse_message_handlers["servers:memory_usage"] = &ScriptEditorDebugger::_msg_servers_memory_usage;
9791014
parse_message_handlers["servers:drawn"] = &ScriptEditorDebugger::_msg_servers_drawn;

editor/debugger/script_editor_debugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ class ScriptEditorDebugger : public MarginContainer {
209209
#ifndef DISABLE_DEPRECATED
210210
void _msg_scene_inspect_object(uint64_t p_thread_id, const Array &p_data);
211211
#endif // DISABLE_DEPRECATED
212+
void _msg_scene_select_path(uint64_t p_thread_id, const Array &p_data);
213+
void _msg_scene_set_object_property(uint64_t p_thread_id, const Array &p_data);
212214
void _msg_scene_debug_mute_audio(uint64_t p_thread_id, const Array &p_data);
213215
void _msg_servers_memory_usage(uint64_t p_thread_id, const Array &p_data);
214216
void _msg_servers_drawn(uint64_t p_thread_id, const Array &p_data);

0 commit comments

Comments
 (0)