Compile out editor-only logic within validate_property in games

This commit is contained in:
LuoZhihao
2025-06-12 12:54:19 +08:00
parent d9cd011e2f
commit 8ba4656ea3
69 changed files with 274 additions and 119 deletions

View File

@@ -116,7 +116,12 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
if (frames.is_null()) {
return;
}
if (!Engine::get_singleton()->is_editor_hint()) {
if (p_property.name == "frame" && playing) {
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
}
return;
}
if (p_property.name == "animation") {
List<StringName> names;
frames->get_animation_list(&names);

View File

@@ -80,6 +80,9 @@ BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
}
void BackBufferCopy::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (copy_mode != COPY_MODE_RECT && p_property.name == "rect") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@@ -616,7 +616,7 @@ void CPUParticles2D::request_particles_process(real_t p_requested_process_time)
}
void CPUParticles2D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "emitting") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "emitting") {
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
}

View File

@@ -431,7 +431,7 @@ void GPUParticles2D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "seed" && !use_fixed_seed) {
p_property.usage = PROPERTY_USAGE_NONE;
}
if (p_property.name == "emitting") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "emitting") {
p_property.hint = one_shot ? PROPERTY_HINT_ONESHOT : PROPERTY_HINT_NONE;
}
}

View File

@@ -243,6 +243,9 @@ real_t Light2D::get_shadow_smooth() const {
}
void Light2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (shadow && p_property.name == "shadow_filter_smooth" && shadow_filter == SHADOW_FILTER_NONE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@@ -364,6 +364,9 @@ bool PathFollow2D::is_cubic_interpolation_enabled() const {
}
void PathFollow2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "offset") {
real_t max = 10000.0;
if (path && path->get_curve().is_valid()) {

View File

@@ -541,6 +541,9 @@ StringName Area2D::get_audio_bus_name() const {
}
void Area2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "audio_bus_name") {
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {

View File

@@ -646,6 +646,9 @@ void CharacterBody2D::_notification(int p_what) {
}
void CharacterBody2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (motion_mode == MOTION_MODE_FLOATING) {
if (p_property.name.begins_with("floor_") || p_property.name == "up_direction" || p_property.name == "slide_on_ceiling") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@@ -790,6 +790,9 @@ void RigidBody2D::_bind_methods() {
}
void RigidBody2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM && p_property.name == "center_of_mass") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@@ -461,6 +461,9 @@ Rect2 Sprite2D::get_rect() const {
}
void Sprite2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "frame") {
p_property.hint = PROPERTY_HINT_RANGE;
p_property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";

View File

@@ -2203,6 +2203,9 @@ void TileMapLayer::_bind_methods() {
}
void TileMapLayer::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (is_y_sort_enabled()) {
if (p_property.name == "rendering_quadrant_size") {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;