mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Visibility rect only shown when a GPUParticle2D is selected to reduce visual clutter in scenes with a lot of Particle nodes.
This commit is contained in:
parent
dd10213d6e
commit
37cfa56db3
5 changed files with 43 additions and 4 deletions
|
@ -57,6 +57,27 @@ void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
|
|||
emission_mask->popup_centered();
|
||||
}
|
||||
|
||||
void GPUParticles2DEditorPlugin::_selection_changed() {
|
||||
List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list();
|
||||
|
||||
if (selected_particles.is_empty() && selected_nodes.is_empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (GPUParticles2D *SP : selected_particles) {
|
||||
SP->set_show_visibility_rect(false);
|
||||
}
|
||||
selected_particles.clear();
|
||||
|
||||
for (Node *P : selected_nodes) {
|
||||
GPUParticles2D *selected_particle = Object::cast_to<GPUParticles2D>(P);
|
||||
if (selected_particle != nullptr) {
|
||||
selected_particle->set_show_visibility_rect(true);
|
||||
selected_particles.push_back(selected_particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||
switch (p_idx) {
|
||||
case MENU_GENERATE_VISIBILITY_RECT: {
|
||||
|
@ -334,6 +355,7 @@ void GPUParticles2DEditorPlugin::_notification(int p_what) {
|
|||
menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
|
||||
menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons")));
|
||||
file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
|
||||
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue