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

@@ -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;
}