mirror of
https://github.com/godotengine/godot.git
synced 2025-01-30 21:33:18 +08:00
Merge pull request #26706 from YeldhamDev/multinode_scriptclear_fix
Fix clearing scripts while multiple nodes are selected
This commit is contained in:
commit
c1fae20400
@ -377,7 +377,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|||||||
} break;
|
} break;
|
||||||
case TOOL_CLEAR_SCRIPT: {
|
case TOOL_CLEAR_SCRIPT: {
|
||||||
|
|
||||||
List<Node *> selection = editor_selection->get_selected_node_list();
|
Array selection = editor_selection->get_selected_nodes();
|
||||||
|
|
||||||
if (selection.empty())
|
if (selection.empty())
|
||||||
return;
|
return;
|
||||||
@ -385,13 +385,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
|||||||
editor_data->get_undo_redo().create_action(TTR("Clear Script"));
|
editor_data->get_undo_redo().create_action(TTR("Clear Script"));
|
||||||
editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL);
|
editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL);
|
||||||
|
|
||||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
for (int i = 0; i < selection.size(); i++) {
|
||||||
|
|
||||||
Ref<Script> existing = E->get()->get_script();
|
Node *n = Object::cast_to<Node>(selection[i]);
|
||||||
|
Ref<Script> existing = n->get_script();
|
||||||
if (existing.is_valid()) {
|
if (existing.is_valid()) {
|
||||||
const RefPtr empty;
|
const RefPtr empty;
|
||||||
editor_data->get_undo_redo().add_do_method(E->get(), "set_script", empty);
|
editor_data->get_undo_redo().add_do_method(n, "set_script", empty);
|
||||||
editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing);
|
editor_data->get_undo_redo().add_undo_method(n, "set_script", existing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,9 +1654,9 @@ void SceneTreeDock::_update_script_button() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
button_create_script->show();
|
button_create_script->show();
|
||||||
List<Node *> selection = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
Array selection = editor_selection->get_selected_nodes();
|
||||||
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
|
for (int i = 0; i < selection.size(); i++) {
|
||||||
Node *n = E->get();
|
Node *n = Object::cast_to<Node>(selection[i]);
|
||||||
if (!n->get_script().is_null()) {
|
if (!n->get_script().is_null()) {
|
||||||
button_clear_script->show();
|
button_clear_script->show();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user