MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _node_set_func

Method _node_set_func

scene/debugger/scene_debugger.cpp:1017–1079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1015}
1016
1017void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
1018 SceneTree *scene_tree = SceneTree::get_singleton();
1019 if (!scene_tree) {
1020 return;
1021 }
1022
1023 if (!live_edit_node_path_cache.has(p_id)) {
1024 return;
1025 }
1026
1027 NodePath np = live_edit_node_path_cache[p_id];
1028 Node *base = nullptr;
1029 if (scene_tree->root->has_node(live_edit_root)) {
1030 base = scene_tree->root->get_node(live_edit_root);
1031 }
1032
1033 HashMap<String, HashSet<Node *>>::Iterator E = live_scene_edit_cache.find(live_edit_scene);
1034 if (!E) {
1035 return; //scene not editable
1036 }
1037
1038 for (Node *F : E->value) {
1039 Node *n = F;
1040
1041 if (base && !base->is_ancestor_of(n)) {
1042 continue;
1043 }
1044
1045 if (!n->has_node(np)) {
1046 continue;
1047 }
1048 Node *n2 = n->get_node(np);
1049
1050 // Do not change transform of edited scene root, unless it's the scene being played.
1051 // See GH-86659 for additional context.
1052 bool keep_transform = (n2 == n) && (n2->get_parent() != scene_tree->root);
1053 Variant orig_tf;
1054
1055 if (keep_transform) {
1056 if (n2->is_class("Node3D")) {
1057 orig_tf = n2->call("get_transform");
1058 } else if (n2->is_class("CanvasItem")) {
1059 orig_tf = n2->call("_edit_get_state");
1060 }
1061 }
1062
1063 n2->set(p_prop, p_value);
1064
1065 if (keep_transform) {
1066 if (n2->is_class("Node3D")) {
1067 Variant new_tf = n2->call("get_transform");
1068 if (new_tf != orig_tf) {
1069 n2->call("set_transform", orig_tf);
1070 }
1071 } else if (n2->is_class("CanvasItem")) {
1072 Variant new_tf = n2->call("_edit_get_state");
1073 if (new_tf != orig_tf) {
1074 n2->call("_edit_set_state", orig_tf);

Callers 1

_msg_live_node_propMethod · 0.80

Calls 9

is_ancestor_ofMethod · 0.80
hasMethod · 0.45
has_nodeMethod · 0.45
get_nodeMethod · 0.45
findMethod · 0.45
get_parentMethod · 0.45
is_classMethod · 0.45
callMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected