Skip to content

Commit adbd78a

Browse files
committed
AnimationTree: Fix libraries is stored
1 parent 2dd26a0 commit adbd78a

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

scene/animation/animation_mixer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,12 @@ bool AnimationMixer::_get(const StringName &p_name, Variant &r_ret) const {
106106
return true;
107107
}
108108

109+
uint32_t AnimationMixer::_get_libraries_property_usage() const {
110+
return PROPERTY_USAGE_DEFAULT;
111+
}
112+
109113
void AnimationMixer::_get_property_list(List<PropertyInfo> *p_list) const {
110-
p_list->push_back(PropertyInfo(Variant::DICTIONARY, PNAME("libraries"), PROPERTY_HINT_DICTIONARY_TYPE, "StringName;AnimationLibrary"));
114+
p_list->push_back(PropertyInfo(Variant::DICTIONARY, PNAME("libraries"), PROPERTY_HINT_DICTIONARY_TYPE, "StringName;AnimationLibrary", _get_libraries_property_usage()));
111115
}
112116

113117
void AnimationMixer::_validate_property(PropertyInfo &p_property) const {

scene/animation/animation_mixer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ class AnimationMixer : public Node {
338338

339339
bool _set(const StringName &p_name, const Variant &p_value);
340340
bool _get(const StringName &p_name, Variant &r_ret) const;
341+
virtual uint32_t _get_libraries_property_usage() const;
341342
void _get_property_list(List<PropertyInfo> *p_list) const;
342343
void _notification(int p_what);
343344
virtual void _validate_property(PropertyInfo &p_property) const;

scene/animation/animation_tree.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,15 +899,23 @@ void AnimationTree::_setup_animation_player() {
899899
clear_caches();
900900
}
901901

902+
// `libraries` is a dynamic property, so we can't use `_validate_property` to change it.
903+
uint32_t AnimationTree::_get_libraries_property_usage() const {
904+
if (!animation_player.is_empty()) {
905+
return PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
906+
}
907+
return PROPERTY_USAGE_DEFAULT;
908+
}
909+
902910
void AnimationTree::_validate_property(PropertyInfo &p_property) const {
911+
if (!Engine::get_singleton()->is_editor_hint()) {
912+
return;
913+
}
914+
903915
if (!animation_player.is_empty()) {
904-
if (Engine::get_singleton()->is_editor_hint() && (p_property.name == "root_node" || p_property.name.begins_with("libraries"))) {
916+
if (p_property.name == "root_node") {
905917
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
906918
}
907-
908-
if (p_property.name.begins_with("libraries")) {
909-
p_property.usage &= ~PROPERTY_USAGE_STORAGE;
910-
}
911919
}
912920
}
913921

scene/animation/animation_tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class AnimationTree : public AnimationMixer {
312312

313313
bool _set(const StringName &p_name, const Variant &p_value);
314314
bool _get(const StringName &p_name, Variant &r_ret) const;
315+
virtual uint32_t _get_libraries_property_usage() const override;
315316
void _get_property_list(List<PropertyInfo> *p_list) const;
316317
virtual void _validate_property(PropertyInfo &p_property) const override;
317318
void _notification(int p_what);

0 commit comments

Comments
 (0)