@@ -113,56 +113,60 @@ Rect2 AnimatedSprite2D::_get_rect() const {
113113}
114114
115115void AnimatedSprite2D::_validate_property (PropertyInfo &p_property) const {
116- if (frames.is_null ()) {
117- return ;
118- }
116+ #if TOOLS_ENABLED
117+ if (Engine::get_singleton ()->is_editor_hint ()) {
118+ if (frames.is_null ()) {
119+ return ;
120+ }
119121
120- if (p_property.name == " animation" ) {
121- List<StringName> names;
122- frames->get_animation_list (&names);
123- names.sort_custom <StringName::AlphCompare>();
122+ if (p_property.name == " animation" ) {
123+ List<StringName> names;
124+ frames->get_animation_list (&names);
125+ names.sort_custom <StringName::AlphCompare>();
124126
125- bool current_found = false ;
126- bool is_first_element = true ;
127+ bool current_found = false ;
128+ bool is_first_element = true ;
127129
128- for (const StringName &E : names) {
129- if (!is_first_element) {
130- p_property.hint_string += " ," ;
131- } else {
132- is_first_element = false ;
133- }
130+ for (const StringName &E : names) {
131+ if (!is_first_element) {
132+ p_property.hint_string += " ," ;
133+ } else {
134+ is_first_element = false ;
135+ }
134136
135- p_property.hint_string += String (E);
136- if (animation == E) {
137- current_found = true ;
137+ p_property.hint_string += String (E);
138+ if (animation == E) {
139+ current_found = true ;
140+ }
138141 }
139- }
140142
141- if (!current_found) {
142- if (p_property.hint_string .is_empty ()) {
143- p_property.hint_string = String (animation);
144- } else {
145- p_property.hint_string = String (animation) + " ," + p_property.hint_string ;
143+ if (!current_found) {
144+ if (p_property.hint_string .is_empty ()) {
145+ p_property.hint_string = String (animation);
146+ } else {
147+ p_property.hint_string = String (animation) + " ," + p_property.hint_string ;
148+ }
146149 }
147- }
148- return ;
149- }
150-
151- if (p_property.name == " frame" ) {
152- if (playing) {
153- p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
154150 return ;
155151 }
156152
157- p_property.hint = PROPERTY_HINT_RANGE;
158- if (frames->has_animation (animation) && frames->get_frame_count (animation) > 0 ) {
159- p_property.hint_string = " 0," + itos (frames->get_frame_count (animation) - 1 ) + " ,1" ;
160- } else {
161- // Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`.
162- p_property.hint_string = " 0,0,1" ;
153+ if (p_property.name == " frame" ) {
154+ if (playing) {
155+ p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
156+ return ;
157+ }
158+
159+ p_property.hint = PROPERTY_HINT_RANGE;
160+ if (frames->has_animation (animation) && frames->get_frame_count (animation) > 0 ) {
161+ p_property.hint_string = " 0," + itos (frames->get_frame_count (animation) - 1 ) + " ,1" ;
162+ } else {
163+ // Avoid an error, `hint_string` is required for `PROPERTY_HINT_RANGE`.
164+ p_property.hint_string = " 0,0,1" ;
165+ }
166+ p_property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
163167 }
164- p_property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
165168 }
169+ #endif
166170}
167171
168172void AnimatedSprite2D::_notification (int p_what) {
0 commit comments