| 1203 | } |
| 1204 | |
| 1205 | void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name) { |
| 1206 | SceneTree *scene_tree = SceneTree::get_singleton(); |
| 1207 | if (!scene_tree) { |
| 1208 | return; |
| 1209 | } |
| 1210 | |
| 1211 | Node *base = nullptr; |
| 1212 | if (scene_tree->root->has_node(live_edit_root)) { |
| 1213 | base = scene_tree->root->get_node(live_edit_root); |
| 1214 | } |
| 1215 | |
| 1216 | HashMap<String, HashSet<Node *>>::Iterator E = live_scene_edit_cache.find(live_edit_scene); |
| 1217 | if (!E) { |
| 1218 | return; //scene not editable |
| 1219 | } |
| 1220 | |
| 1221 | for (Node *F : E->value) { |
| 1222 | Node *n = F; |
| 1223 | |
| 1224 | if (base && !base->is_ancestor_of(n)) { |
| 1225 | continue; |
| 1226 | } |
| 1227 | |
| 1228 | if (!n->has_node(p_parent)) { |
| 1229 | continue; |
| 1230 | } |
| 1231 | Node *n2 = n->get_node(p_parent); |
| 1232 | |
| 1233 | Node *no = Object::cast_to<Node>(ClassDB::instantiate(p_type)); |
| 1234 | if (!no) { |
| 1235 | continue; |
| 1236 | } |
| 1237 | |
| 1238 | no->set_name(p_name); |
| 1239 | n2->add_child(no); |
| 1240 | } |
| 1241 | } |
| 1242 | |
| 1243 | void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name) { |
| 1244 | SceneTree *scene_tree = SceneTree::get_singleton(); |
no test coverage detected