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

@ -950,6 +950,9 @@ bool CSGShape3D::is_calculating_tangents() const {
}
void CSGShape3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
bool is_collision_prefixed = p_property.name.begins_with("collision_");
if ((is_collision_prefixed || p_property.name.begins_with("use_collision")) && is_inside_tree() && !is_root_shape()) {
//hide collision if not root

View File

@ -416,17 +416,18 @@ String AudioStreamInteractive::_get_streams_hint() const {
}
#endif
void AudioStreamInteractive::_validate_property(PropertyInfo &r_property) const {
String prop = r_property.name;
if (Engine::get_singleton()->is_editor_hint() && prop == "switch_to") {
#ifdef TOOLS_ENABLED
if (prop == "switch_to") {
r_property.hint_string = _get_streams_hint();
#endif
return;
}
#endif
if (prop == "initial_clip") {
if (Engine::get_singleton()->is_editor_hint() && prop == "initial_clip") {
#ifdef TOOLS_ENABLED
r_property.hint_string = _get_streams_hint();
#endif
@ -437,7 +438,7 @@ void AudioStreamInteractive::_validate_property(PropertyInfo &r_property) const
} else if (prop == "clip_" + itos(clip) + "/next_clip") {
if (clips[clip].auto_advance != AUTO_ADVANCE_ENABLED) {
r_property.usage = 0;
} else {
} else if (Engine::get_singleton()->is_editor_hint()) {
#ifdef TOOLS_ENABLED
r_property.hint_string = _get_streams_hint();
#endif

View File

@ -30,6 +30,8 @@
#include "fastnoise_lite.h"
#include "core/config/engine.h"
_FastNoiseLite::FractalType FastNoiseLite::_convert_domain_warp_fractal_type_enum(DomainWarpFractalType p_domain_warp_fractal_type) {
_FastNoiseLite::FractalType type;
switch (p_domain_warp_fractal_type) {
@ -477,6 +479,9 @@ void FastNoiseLite::_bind_methods() {
}
void FastNoiseLite::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
return;

View File

@ -97,6 +97,9 @@ void NoiseTexture2D::_bind_methods() {
}
void NoiseTexture2D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "bump_strength") {
if (!as_normal_map) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@ -83,6 +83,9 @@ void NoiseTexture3D::_bind_methods() {
}
void NoiseTexture3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "seamless_blend_skirt") {
if (!seamless) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@ -677,6 +677,9 @@ bool OpenXRCompositionLayer::_set(const StringName &p_property, const Variant &p
}
void OpenXRCompositionLayer::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "layer_viewport") {
if (use_android_surface) {
p_property.usage &= ~PROPERTY_USAGE_EDITOR;

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;

View File

@ -32,7 +32,7 @@
#include "bone_attachment_3d.compat.inc"
void BoneAttachment3D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "bone_name") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "bone_name") {
// Because it is a constant function, we cannot use the get_skeleton function.
const Skeleton3D *parent = nullptr;
if (use_external_skeleton) {

View File

@ -117,17 +117,19 @@ void Camera3D::_update_camera_mode() {
}
void Camera3D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "fov") {
if (mode != PROJECTION_PERSPECTIVE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
} else if (p_property.name == "size") {
if (mode != PROJECTION_ORTHOGONAL && mode != PROJECTION_FRUSTUM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
} else if (p_property.name == "frustum_offset") {
if (mode != PROJECTION_FRUSTUM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
if (Engine::get_singleton()->is_editor_hint()) {
if (p_property.name == "fov") {
if (mode != PROJECTION_PERSPECTIVE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
} else if (p_property.name == "size") {
if (mode != PROJECTION_ORTHOGONAL && mode != PROJECTION_FRUSTUM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
} else if (p_property.name == "frustum_offset") {
if (mode != PROJECTION_FRUSTUM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
}
}

View File

@ -587,7 +587,7 @@ void CPUParticles3D::request_particles_process(real_t p_requested_process_time)
}
void CPUParticles3D::_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

@ -167,7 +167,7 @@ AABB Decal::get_aabb() const {
}
void Decal::_validate_property(PropertyInfo &p_property) const {
if (!distance_fade_enabled && (p_property.name == "distance_fade_begin" || p_property.name == "distance_fade_length")) {
if (Engine::get_singleton()->is_editor_hint() && !distance_fade_enabled && (p_property.name == "distance_fade_begin" || p_property.name == "distance_fade_length")) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -454,7 +454,7 @@ AABB GPUParticles3D::capture_aabb() const {
}
void GPUParticles3D::_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

@ -180,6 +180,9 @@ void Label3D::_bind_methods() {
}
void Label3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (
p_property.name == "material_override" ||
p_property.name == "material_overlay" ||

View File

@ -541,14 +541,16 @@ DirectionalLight3D::SkyMode DirectionalLight3D::get_sky_mode() const {
}
void DirectionalLight3D::_validate_property(PropertyInfo &p_property) const {
if (shadow_mode == SHADOW_ORTHOGONAL && (p_property.name == "directional_shadow_split_1" || p_property.name == "directional_shadow_blend_splits")) {
// Split 2 and split blending are only used with the PSSM 2 Splits and PSSM 4 Splits shadow modes.
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (Engine::get_singleton()->is_editor_hint()) {
if (shadow_mode == SHADOW_ORTHOGONAL && (p_property.name == "directional_shadow_split_1" || p_property.name == "directional_shadow_blend_splits")) {
// Split 2 and split blending are only used with the PSSM 2 Splits and PSSM 4 Splits shadow modes.
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((shadow_mode == SHADOW_ORTHOGONAL || shadow_mode == SHADOW_PARALLEL_2_SPLITS) && (p_property.name == "directional_shadow_split_2" || p_property.name == "directional_shadow_split_3")) {
// Splits 3 and 4 are only used with the PSSM 4 Splits shadow mode.
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
if ((shadow_mode == SHADOW_ORTHOGONAL || shadow_mode == SHADOW_PARALLEL_2_SPLITS) && (p_property.name == "directional_shadow_split_2" || p_property.name == "directional_shadow_split_3")) {
// Splits 3 and 4 are only used with the PSSM 4 Splits shadow mode.
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
}
if (p_property.name == "light_size" || p_property.name == "light_projector") {

View File

@ -1800,6 +1800,9 @@ PackedStringArray LightmapGI::get_configuration_warnings() const {
}
void LightmapGI::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "supersampling_factor" && !supersampling_enabled) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -31,7 +31,7 @@
#include "look_at_modifier_3d.h"
void LookAtModifier3D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "bone_name" || p_property.name == "origin_bone_name") {
if (Engine::get_singleton()->is_editor_hint() && (p_property.name == "bone_name" || p_property.name == "origin_bone_name")) {
Skeleton3D *skeleton = get_skeleton();
if (skeleton) {
p_property.hint = PROPERTY_HINT_ENUM;

View File

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

View File

@ -645,6 +645,9 @@ float Area3D::get_reverb_uniformity() const {
}
void Area3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "audio_bus_name" || p_property.name == "reverb_bus_name") {
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {

View File

@ -931,6 +931,9 @@ void CharacterBody3D::_bind_methods() {
}
void CharacterBody3D::_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

@ -808,6 +808,9 @@ void RigidBody3D::_bind_methods() {
}
void RigidBody3D::_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

@ -201,6 +201,9 @@ AABB ReflectionProbe::get_aabb() const {
}
void ReflectionProbe::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "ambient_color" || p_property.name == "ambient_color_energy") {
if (ambient_mode != AMBIENT_COLOR) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@ -301,6 +301,9 @@ void FabrikInverseKinematic::_update_chain(const Skeleton3D *p_sk, ChainItem *p_
}
void SkeletonIK3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "root_bone" || p_property.name == "tip_bone") {
Skeleton3D *skeleton = get_skeleton();
if (skeleton) {

View File

@ -30,10 +30,6 @@
#include "skeleton_modifier_3d.h"
void SkeletonModifier3D::_validate_property(PropertyInfo &p_property) const {
//
}
PackedStringArray SkeletonModifier3D::get_configuration_warnings() const {
PackedStringArray warnings = Node3D::get_configuration_warnings();
if (skeleton_id.is_null()) {

View File

@ -65,7 +65,6 @@ protected:
GDVIRTUAL2(_skeleton_changed, Skeleton3D *, Skeleton3D *);
GDVIRTUAL0(_validate_bone_names);
void _validate_property(PropertyInfo &p_property) const;
void _notification(int p_what);
static void _bind_methods();

View File

@ -44,7 +44,7 @@ PackedStringArray SpringBoneCollision3D::get_configuration_warnings() const {
}
void SpringBoneCollision3D::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "bone_name") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "bone_name") {
Skeleton3D *sk = get_skeleton();
if (sk) {
p_property.hint = PROPERTY_HINT_ENUM_SUGGESTION;

View File

@ -964,6 +964,9 @@ Rect2 Sprite3D::get_item_rect() const {
}
void Sprite3D::_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";
@ -1056,7 +1059,12 @@ void AnimatedSprite3D::_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

@ -255,6 +255,9 @@ void XRNode3D::_bind_methods() {
}
void XRNode3D::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL(xr_server);

View File

@ -78,7 +78,7 @@ AnimationNode::NodeTimeInfo AnimationNodeAnimation::get_node_time_info() const {
}
void AnimationNodeAnimation::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "animation" && get_editable_animation_list) {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "animation" && get_editable_animation_list) {
Vector<String> names = get_editable_animation_list();
String anims;
for (int i = 0; i < names.size(); i++) {

View File

@ -111,8 +111,8 @@ void AnimationMixer::_get_property_list(List<PropertyInfo> *p_list) const {
}
void AnimationMixer::_validate_property(PropertyInfo &p_property) const {
#ifdef TOOLS_ENABLED
if (editing && (p_property.name == "active" || p_property.name == "deterministic" || p_property.name == "root_motion_track")) {
#ifdef TOOLS_ENABLED // `editing` is surrounded by TOOLS_ENABLED so this should also be.
if (Engine::get_singleton()->is_editor_hint() && editing && (p_property.name == "active" || p_property.name == "deterministic" || p_property.name == "root_motion_track")) {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
}
#endif // TOOLS_ENABLED

View File

@ -106,7 +106,7 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
}
void AnimationPlayer::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "current_animation") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "current_animation") {
List<String> names;
for (const KeyValue<StringName, AnimationData> &E : animation_set) {

View File

@ -901,9 +901,10 @@ void AnimationTree::_setup_animation_player() {
void AnimationTree::_validate_property(PropertyInfo &p_property) const {
if (!animation_player.is_empty()) {
if (p_property.name == "root_node" || p_property.name.begins_with("libraries")) {
if (Engine::get_singleton()->is_editor_hint() && (p_property.name == "root_node" || p_property.name.begins_with("libraries"))) {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
}
if (p_property.name.begins_with("libraries")) {
p_property.usage &= ~PROPERTY_USAGE_STORAGE;
}

View File

@ -193,6 +193,9 @@ bool AudioStreamPlayerInternal::get_stream_paused() const {
}
void AudioStreamPlayerInternal::validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "bus") {
String options;
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {

View File

@ -458,7 +458,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
void Control::_validate_property(PropertyInfo &p_property) const {
// Update theme type variation options.
if (p_property.name == "theme_type_variation") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "theme_type_variation") {
List<StringName> names;
ThemeDB::get_singleton()->get_default_theme()->get_type_variation_list(get_class_name(), &names);
@ -505,20 +505,19 @@ void Control::_validate_property(PropertyInfo &p_property) const {
p_property.hint_string = hint_string;
}
if (p_property.name == "mouse_force_pass_scroll_events") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "mouse_force_pass_scroll_events") {
// Disable force pass if the control is not stopping the event.
if (data.mouse_filter != MOUSE_FILTER_STOP) {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
}
}
if (p_property.name == "scale") {
if (Engine::get_singleton()->is_editor_hint() && p_property.name == "scale") {
p_property.hint = PROPERTY_HINT_LINK;
}
// Validate which positioning properties should be displayed depending on the parent and the layout mode.
Control *parent_control = get_parent_control();
if (!parent_control) {
if (Engine::get_singleton()->is_editor_hint() && !parent_control) {
// If there is no parent control, display both anchor and container options.
// Set the layout mode to be disabled with the proper value.
@ -538,11 +537,11 @@ void Control::_validate_property(PropertyInfo &p_property) const {
p_property.usage ^= PROPERTY_USAGE_DEFAULT;
} else if (p_property.name == "position" || p_property.name == "rotation" || p_property.name == "scale" || p_property.name == "size" || p_property.name == "pivot_offset") {
p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
} else if (p_property.name == "layout_mode") {
} else if (Engine::get_singleton()->is_editor_hint() && p_property.name == "layout_mode") {
// Set the layout mode to be disabled with the proper value.
p_property.hint_string = "Position,Anchors,Container,Uncontrolled";
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
} else if (p_property.name == "size_flags_horizontal" || p_property.name == "size_flags_vertical") {
} else if (Engine::get_singleton()->is_editor_hint() && (p_property.name == "size_flags_horizontal" || p_property.name == "size_flags_vertical")) {
// Filter allowed size flags based on the parent container configuration.
Container *parent_container = Object::cast_to<Container>(parent_control);
Vector<int> size_flags;
@ -583,7 +582,7 @@ void Control::_validate_property(PropertyInfo &p_property) const {
p_property.hint_string = hint_string;
}
}
} else {
} else if (Engine::get_singleton()->is_editor_hint()) {
// If the parent is a non-container control, display only anchoring-related properties.
if (p_property.name.begins_with("size_flags_")) {
p_property.usage ^= PROPERTY_USAGE_EDITOR;
@ -604,7 +603,9 @@ void Control::_validate_property(PropertyInfo &p_property) const {
p_property.usage ^= PROPERTY_USAGE_EDITOR;
}
}
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
// Disable the property if it's managed by the parent container.
if (!Object::cast_to<Container>(parent_control)) {
return;

View File

@ -448,6 +448,9 @@ void AcceptDialog::_bind_methods() {
}
void AcceptDialog::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "ok_button_text") {
p_property.hint = PROPERTY_HINT_PLACEHOLDER_TEXT;
p_property.hint_string = default_ok_text;

View File

@ -88,6 +88,9 @@ void GraphElement::_notification(int p_what) {
}
void GraphElement::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent());
if (graph) {
if (p_property.name == "position") {

View File

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

View File

@ -3102,6 +3102,9 @@ void LineEdit::_update_context_menu() {
}
void LineEdit::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (!caret_blink_enabled && p_property.name == "caret_blink_interval") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -148,6 +148,9 @@ void Popup::_post_popup() {
}
void Popup::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (
p_property.name == "transient" ||
p_property.name == "exclusive" ||

View File

@ -186,7 +186,7 @@ void ProgressBar::_notification(int p_what) {
}
void ProgressBar::_validate_property(PropertyInfo &p_property) const {
if (indeterminate && p_property.name == "show_percentage") {
if (Engine::get_singleton()->is_editor_hint() && indeterminate && p_property.name == "show_percentage") {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
}
if (!indeterminate && p_property.name == "editor_preview_indeterminate") {

View File

@ -367,6 +367,9 @@ void Slider::_notification(int p_what) {
}
void Slider::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "ticks_position") {
p_property.hint_string = orientation == VERTICAL ? "Right,Left,Both,Center" : "Bottom,Top,Both,Center";
}

View File

@ -636,6 +636,9 @@ Point2 TextureProgressBar::get_radial_center_offset() {
}
void TextureProgressBar::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name.begins_with("stretch_margin_") && !nine_patch_stretch) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

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

View File

@ -5294,6 +5294,9 @@ void Viewport::_bind_methods() {
}
void Viewport::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (vrs_mode != VRS_TEXTURE && (p_property.name == "vrs_texture")) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
@ -5555,6 +5558,9 @@ void SubViewport::_bind_methods() {
}
void SubViewport::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "size") {
SubViewportContainer *parent_svc = Object::cast_to<SubViewportContainer>(get_parent());
if (parent_svc && parent_svc->is_stretch_enabled()) {

View File

@ -244,7 +244,7 @@ void Window::_validate_property(PropertyInfo &p_property) const {
if (initial_position != WINDOW_INITIAL_POSITION_CENTER_OTHER_SCREEN) {
p_property.usage = PROPERTY_USAGE_NONE;
}
} else if (p_property.name == "theme_type_variation") {
} else if (Engine::get_singleton()->is_editor_hint() && p_property.name == "theme_type_variation") {
List<StringName> names;
ThemeDB::get_singleton()->get_default_theme()->get_type_variation_list(get_class_name(), &names);

View File

@ -4233,6 +4233,9 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
}
void TileSet::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "tile_layout" && tile_shape == TILE_SHAPE_SQUARE) {
p_property.usage ^= PROPERTY_USAGE_READ_ONLY;
} else if (p_property.name == "tile_offset_axis" && tile_shape == TILE_SHAPE_SQUARE) {

View File

@ -211,6 +211,9 @@ RID ProceduralSkyMaterial::get_shader_rid() const {
}
void ProceduralSkyMaterial::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if ((p_property.name == "sky_luminance" || p_property.name == "ground_luminance") && !GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units")) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
@ -652,6 +655,9 @@ RID PhysicalSkyMaterial::get_shader_rid() const {
}
void PhysicalSkyMaterial::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "exposure_value" && !GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units")) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -171,6 +171,9 @@ void BoneMap::_bind_methods() {
}
void BoneMap::_validate_property(PropertyInfo &property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (property.name == "bonemap" || property.name == "profile") {
property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -96,6 +96,9 @@ RID CameraAttributes::get_rid() const {
}
void CameraAttributes::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (!GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units") && p_property.name == "exposure_sensitivity") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
return;
@ -253,6 +256,9 @@ void CameraAttributesPractical::_update_auto_exposure() {
}
void CameraAttributesPractical::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if ((!dof_blur_far_enabled && (p_property.name == "dof_blur_far_distance" || p_property.name == "dof_blur_far_transition")) ||
(!dof_blur_near_enabled && (p_property.name == "dof_blur_near_distance" || p_property.name == "dof_blur_near_transition"))) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
@ -447,6 +453,9 @@ void CameraAttributesPhysical::_update_auto_exposure() {
}
void CameraAttributesPhysical::_validate_property(PropertyInfo &property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (!GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units") && (property.name == "exposure_aperture" || property.name == "exposure_shutter_speed")) {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
return;

View File

@ -293,9 +293,6 @@ void CompressedTexture2D::reload_from_file() {
load(path);
}
void CompressedTexture2D::_validate_property(PropertyInfo &p_property) const {
}
Ref<Image> CompressedTexture2D::load_image_from_file(Ref<FileAccess> f, int p_size_limit) {
uint32_t data_format = f->get_32();
uint32_t w = f->get_16();
@ -634,9 +631,6 @@ void CompressedTexture3D::reload_from_file() {
load(path);
}
void CompressedTexture3D::_validate_property(PropertyInfo &p_property) const {
}
void CompressedTexture3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("load", "path"), &CompressedTexture3D::load);
ClassDB::bind_method(D_METHOD("get_load_path"), &CompressedTexture3D::get_load_path);
@ -826,9 +820,6 @@ void CompressedTextureLayered::reload_from_file() {
load(path);
}
void CompressedTextureLayered::_validate_property(PropertyInfo &p_property) const {
}
void CompressedTextureLayered::_bind_methods() {
ClassDB::bind_method(D_METHOD("load", "path"), &CompressedTextureLayered::load);
ClassDB::bind_method(D_METHOD("get_load_path"), &CompressedTextureLayered::get_load_path);

View File

@ -76,7 +76,6 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
public:
static Ref<Image> load_image_from_file(Ref<FileAccess> p_file, int p_size_limit);
@ -153,7 +152,6 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
public:
Image::Format get_format() const override;
@ -240,7 +238,6 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &p_property) const;
public:
Image::Format get_format() const override;

View File

@ -1082,6 +1082,9 @@ void Environment::_update_adjustment() {
// Private methods, constructor and destructor
void Environment::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "sky" || p_property.name == "sky_custom_fov" || p_property.name == "sky_rotation" || p_property.name == "ambient_light_sky_contribution") {
if (bg_mode != BG_SKY && ambient_source != AMBIENT_SOURCE_SKY && reflection_source != REFLECTION_SOURCE_SKY) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@ -1069,6 +1069,9 @@ void FontFile::_bind_methods() {
}
void FontFile::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "fallbacks") {
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
}

View File

@ -30,6 +30,8 @@
#include "gradient.h"
#include "core/config/engine.h"
Gradient::Gradient() {
//Set initial gradient transition from black to white
points.resize(2);
@ -88,6 +90,9 @@ void Gradient::_bind_methods() {
}
void Gradient::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "interpolation_color_space" && interpolation_mode == GRADIENT_INTERPOLATE_CONSTANT) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -2564,48 +2564,50 @@ void BaseMaterial3D::_validate_property(PropertyInfo &p_property) const {
p_property.usage = PROPERTY_USAGE_NONE;
}
if (p_property.name == "billboard_keep_scale" && billboard_mode == BILLBOARD_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (Engine::get_singleton()->is_editor_hint()) {
if (p_property.name == "billboard_keep_scale" && billboard_mode == BILLBOARD_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "grow_amount" && !grow_enabled) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "grow_amount" && !grow_enabled) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "point_size" && !flags[FLAG_USE_POINT_SIZE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "point_size" && !flags[FLAG_USE_POINT_SIZE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "proximity_fade_distance" && !proximity_fade_enabled) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "proximity_fade_distance" && !proximity_fade_enabled) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "msdf_pixel_range" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "msdf_pixel_range" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "msdf_outline_size" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "msdf_outline_size" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "distance_fade_max_distance" || p_property.name == "distance_fade_min_distance") && distance_fade == DISTANCE_FADE_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "distance_fade_max_distance" || p_property.name == "distance_fade_min_distance") && distance_fade == DISTANCE_FADE_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "uv1_triplanar_sharpness" || p_property.name == "uv1_world_triplanar") && !flags[FLAG_UV1_USE_TRIPLANAR]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "uv1_triplanar_sharpness" || p_property.name == "uv1_world_triplanar") && !flags[FLAG_UV1_USE_TRIPLANAR]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "uv2_triplanar_sharpness" || p_property.name == "uv2_world_triplanar") && !flags[FLAG_UV2_USE_TRIPLANAR]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "uv2_triplanar_sharpness" || p_property.name == "uv2_world_triplanar") && !flags[FLAG_UV2_USE_TRIPLANAR]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "z_clip_scale" && !flags[FLAG_USE_Z_CLIP_SCALE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "z_clip_scale" && !flags[FLAG_USE_Z_CLIP_SCALE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "fov_override" && !flags[FLAG_USE_FOV_OVERRIDE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
if (p_property.name == "fov_override" && !flags[FLAG_USE_FOV_OVERRIDE]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
}
// you can only enable anti-aliasing (in materials) on alpha scissor and alpha hash
@ -2640,24 +2642,26 @@ void BaseMaterial3D::_validate_property(PropertyInfo &p_property) const {
p_property.usage = PROPERTY_USAGE_NONE;
}
if (p_property.name == "depth_test" && flags[FLAG_DISABLE_DEPTH_TEST]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (Engine::get_singleton()->is_editor_hint()) {
if (p_property.name == "depth_test" && flags[FLAG_DISABLE_DEPTH_TEST]) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "stencil_reference" && stencil_mode == STENCIL_MODE_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "stencil_reference" && stencil_mode == STENCIL_MODE_DISABLED) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "stencil_flags" || p_property.name == "stencil_compare") && stencil_mode != STENCIL_MODE_CUSTOM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "stencil_flags" || p_property.name == "stencil_compare") && stencil_mode != STENCIL_MODE_CUSTOM) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "stencil_color" && stencil_mode != STENCIL_MODE_OUTLINE && stencil_mode != STENCIL_MODE_XRAY) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "stencil_color" && stencil_mode != STENCIL_MODE_OUTLINE && stencil_mode != STENCIL_MODE_XRAY) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.name == "stencil_outline_thickness" && stencil_mode != STENCIL_MODE_OUTLINE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
if (p_property.name == "stencil_outline_thickness" && stencil_mode != STENCIL_MODE_OUTLINE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
}
if (flags[FLAG_SUBSURFACE_MODE_SKIN] && (p_property.name == "subsurf_scatter_transmittance_color" || p_property.name == "subsurf_scatter_transmittance_texture")) {

View File

@ -1924,15 +1924,18 @@ void ParticleProcessMaterial::_validate_property(PropertyInfo &p_property) const
if ((p_property.name == "directional_velocity_min" || p_property.name == "directional_velocity_max") && !tex_parameters[PARAM_DIRECTIONAL_VELOCITY].is_valid()) {
p_property.usage = PROPERTY_USAGE_NONE;
}
if ((p_property.name == "scale_over_velocity_min" || p_property.name == "scale_over_velocity_max") && !tex_parameters[PARAM_SCALE_OVER_VELOCITY].is_valid()) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "orbit_velocity_min" || p_property.name == "orbit_velocity_max") && (!tex_parameters[PARAM_ORBIT_VELOCITY].is_valid() && !particle_flags[PARTICLE_FLAG_DISABLE_Z])) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.usage & PROPERTY_USAGE_EDITOR && (p_property.name.ends_with("_min") || p_property.name.ends_with("_max"))) {
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
if (Engine::get_singleton()->is_editor_hint()) {
if ((p_property.name == "scale_over_velocity_min" || p_property.name == "scale_over_velocity_max") && !tex_parameters[PARAM_SCALE_OVER_VELOCITY].is_valid()) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if ((p_property.name == "orbit_velocity_min" || p_property.name == "orbit_velocity_max") && (!tex_parameters[PARAM_ORBIT_VELOCITY].is_valid() && !particle_flags[PARTICLE_FLAG_DISABLE_Z])) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
if (p_property.usage & PROPERTY_USAGE_EDITOR && (p_property.name.ends_with("_min") || p_property.name.ends_with("_max"))) {
p_property.usage &= ~PROPERTY_USAGE_EDITOR;
}
}
}

View File

@ -133,6 +133,9 @@ bool SkeletonProfile::_get(const StringName &p_path, Variant &r_ret) const {
}
void SkeletonProfile::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (is_read_only) {
if (p_property.name == ("group_size") || p_property.name == ("bone_size") || p_property.name == ("root_bone") || p_property.name == ("scale_base_bone")) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;

View File

@ -40,6 +40,9 @@ float StyleBoxFlat::get_style_margin(Side p_side) const {
}
void StyleBoxFlat::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (!anti_aliased && p_property.name == "anti_aliasing_size") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}

View File

@ -3790,6 +3790,9 @@ String VisualShaderNodeInput::get_input_index_name(int p_index) const {
}
void VisualShaderNodeInput::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "input_name") {
String port_list;

View File

@ -185,6 +185,9 @@ StringName AudioEffectCompressor::get_sidechain() const {
}
void AudioEffectCompressor::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (p_property.name == "sidechain") {
String buses = "";
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {