summaryrefslogtreecommitdiff
path: root/scene/3d/bone_attachment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/bone_attachment.cpp')
-rw-r--r--scene/3d/bone_attachment.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index 3882b8548b..a875b65c22 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -30,43 +30,27 @@
#include "bone_attachment.h"
-bool BoneAttachment::_get(const StringName &p_name, Variant &r_ret) const {
+void BoneAttachment::_validate_property(PropertyInfo &property) const {
- if (String(p_name) == "bone_name") {
+ if (property.name == "bone_name") {
+ Skeleton *parent = Object::cast_to<Skeleton>(get_parent());
- r_ret = get_bone_name();
- return true;
- }
-
- return false;
-}
-bool BoneAttachment::_set(const StringName &p_name, const Variant &p_value) {
-
- if (String(p_name) == "bone_name") {
-
- set_bone_name(p_value);
- return true;
- }
+ if (parent) {
- return false;
-}
-void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
-
- Skeleton *parent = Object::cast_to<Skeleton>(get_parent());
+ String names;
+ for (int i = 0; i < parent->get_bone_count(); i++) {
+ if (i > 0)
+ names += ",";
+ names += parent->get_bone_name(i);
+ }
- if (parent) {
+ property.hint = PROPERTY_HINT_ENUM;
+ property.hint_string = names;
+ } else {
- String names;
- for (int i = 0; i < parent->get_bone_count(); i++) {
- if (i > 0)
- names += ",";
- names += parent->get_bone_name(i);
+ property.hint = PROPERTY_HINT_NONE;
+ property.hint_string = "";
}
-
- p_list->push_back(PropertyInfo(Variant::STRING, "bone_name", PROPERTY_HINT_ENUM, names));
- } else {
-
- p_list->push_back(PropertyInfo(Variant::STRING, "bone_name"));
}
}
@@ -138,4 +122,6 @@ BoneAttachment::BoneAttachment() {
void BoneAttachment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name);
ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment::get_bone_name);
+
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "bone_name"), "set_bone_name", "get_bone_name");
}