AnimationTree: Fix libraries is stored

This commit is contained in:
Luo Zhihao 2025-09-11 09:40:28 +08:00
parent 2dd26a027a
commit adbd78af91
No known key found for this signature in database
GPG key ID: E10A25B618BD1E9B
4 changed files with 21 additions and 7 deletions

View file

@ -106,8 +106,12 @@ bool AnimationMixer::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
uint32_t AnimationMixer::_get_libraries_property_usage() const {
return PROPERTY_USAGE_DEFAULT;
}
void AnimationMixer::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::DICTIONARY, PNAME("libraries"), PROPERTY_HINT_DICTIONARY_TYPE, "StringName;AnimationLibrary"));
p_list->push_back(PropertyInfo(Variant::DICTIONARY, PNAME("libraries"), PROPERTY_HINT_DICTIONARY_TYPE, "StringName;AnimationLibrary", _get_libraries_property_usage()));
}
void AnimationMixer::_validate_property(PropertyInfo &p_property) const {

View file

@ -338,6 +338,7 @@ protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
virtual uint32_t _get_libraries_property_usage() const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
virtual void _validate_property(PropertyInfo &p_property) const;

View file

@ -899,14 +899,22 @@ void AnimationTree::_setup_animation_player() {
clear_caches();
}
void AnimationTree::_validate_property(PropertyInfo &p_property) const {
// `libraries` is a dynamic property, so we can't use `_validate_property` to change it.
uint32_t AnimationTree::_get_libraries_property_usage() const {
if (!animation_player.is_empty()) {
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;
}
return PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
}
return PROPERTY_USAGE_DEFAULT;
}
if (p_property.name.begins_with("libraries")) {
p_property.usage &= ~PROPERTY_USAGE_STORAGE;
void AnimationTree::_validate_property(PropertyInfo &p_property) const {
if (!Engine::get_singleton()->is_editor_hint()) {
return;
}
if (!animation_player.is_empty()) {
if (p_property.name == "root_node") {
p_property.usage |= PROPERTY_USAGE_READ_ONLY;
}
}
}

View file

@ -312,6 +312,7 @@ private:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
virtual uint32_t _get_libraries_property_usage() const override;
void _get_property_list(List<PropertyInfo> *p_list) const;
virtual void _validate_property(PropertyInfo &p_property) const override;
void _notification(int p_what);