diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index b685dea0446..a66df4dc88d 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -41,6 +41,13 @@ void CPUParticles2D::set_emitting(bool p_emitting) { return; } + if (p_emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } + emitting = p_emitting; if (emitting) { active = true; @@ -77,6 +84,13 @@ void CPUParticles2D::set_lifetime(double p_lifetime) { void CPUParticles2D::set_one_shot(bool p_one_shot) { one_shot = p_one_shot; + + if (emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } } void CPUParticles2D::set_pre_process_time(double p_time) { @@ -543,7 +557,7 @@ void CPUParticles2D::_validate_property(PropertyInfo &p_property) const { if (p_property.name == "autostart") { if (emitting && !one_shot) { - p_property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY; } } diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index 2b8056c134c..194c8a7d40f 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -43,6 +43,12 @@ void GPUParticles2D::set_emitting(bool p_emitting) { // Do not return even if `p_emitting == emitting` because `emitting` is just an approximation. + if (p_emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } if (p_emitting && one_shot) { if (!active && !emitting) { // Last cycle ended. @@ -78,6 +84,7 @@ void GPUParticles2D::set_amount(int p_amount) { } void GPUParticles2D::set_lifetime(double p_lifetime) { + ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; RS::get_singleton()->particles_set_lifetime(particles, lifetime); @@ -85,6 +92,12 @@ void GPUParticles2D::set_lifetime(double p_lifetime) { void GPUParticles2D::set_one_shot(bool p_enable) { one_shot = p_enable; + if (emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { @@ -394,7 +407,7 @@ Ref GPUParticles2D::get_texture() const { void GPUParticles2D::_validate_property(PropertyInfo &p_property) const { if (p_property.name == "autostart") { if (emitting && !one_shot) { - p_property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY; } } } diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 76a9fb5681a..fddcec401d2 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -47,6 +47,13 @@ void CPUParticles3D::set_emitting(bool p_emitting) { return; } + if (p_emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } + emitting = p_emitting; if (emitting) { active = true; @@ -90,6 +97,13 @@ void CPUParticles3D::set_lifetime(double p_lifetime) { void CPUParticles3D::set_one_shot(bool p_one_shot) { one_shot = p_one_shot; + + if (emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } } void CPUParticles3D::set_pre_process_time(double p_time) { @@ -581,7 +595,7 @@ void CPUParticles3D::_validate_property(PropertyInfo &p_property) const { if (p_property.name == "autostart") { if (emitting && !one_shot) { - p_property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY; } } } diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 0e4bb3fbf2f..578c2839ad8 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -42,6 +42,13 @@ AABB GPUParticles3D::get_aabb() const { void GPUParticles3D::set_emitting(bool p_emitting) { // Do not return even if `p_emitting == emitting` because `emitting` is just an approximation. + if (p_emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } + if (p_emitting && one_shot) { if (!active && !emitting) { // Last cycle ended. @@ -90,7 +97,15 @@ void GPUParticles3D::set_interp_to_end(float p_interp) { } void GPUParticles3D::set_one_shot(bool p_one_shot) { + one_shot = p_one_shot; + + if (emitting && !one_shot) { + autostart = false; + notify_property_list_changed(); + } else { + notify_property_list_changed(); + } RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { @@ -432,7 +447,7 @@ void GPUParticles3D::_validate_property(PropertyInfo &p_property) const { if (p_property.name == "autostart") { if (emitting && !one_shot) { - p_property.usage = PROPERTY_USAGE_NONE; + p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY; } } }