Skip to content

Commit

Permalink
Merge pull request #54527 from nekomatata/fix-polygon-bone-path-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Nov 3, 2021
2 parents bbee193 + 8d9619a commit 25bea73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scene/2d/polygon_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@ void Polygon2D::set_bone_path(int p_index, const NodePath &p_path) {
Array Polygon2D::_get_bones() const {
Array bones;
for (int i = 0; i < get_bone_count(); i++) {
bones.push_back(get_bone_path(i));
// Convert path property to String to avoid errors due to invalid node path in editor,
// because it's relative to the Skeleton2D node and not Polygon2D.
bones.push_back(String(get_bone_path(i)));
bones.push_back(get_bone_weights(i));
}
return bones;
Expand All @@ -564,7 +566,8 @@ void Polygon2D::_set_bones(const Array &p_bones) {
ERR_FAIL_COND(p_bones.size() & 1);
clear_bones();
for (int i = 0; i < p_bones.size(); i += 2) {
add_bone(p_bones[i], p_bones[i + 1]);
// Convert back from String to NodePath.
add_bone(NodePath(p_bones[i]), p_bones[i + 1]);
}
}

Expand Down

0 comments on commit 25bea73

Please sign in to comment.