using UnityEngine;
using UnityEditor.Animations;

public class SkeletonTreeTraversal : MonoBehaviour
{
    public Transform skeletonRoot; // 骨骼树的根节点
    private List<string> boneNames = new List<string>(); // 用于存储骨骼名的列表

    void Start()
    {
        TraverseSkeleton(skeletonRoot);
        foreach (string name in boneNames)
        {
            Debug.Log(name);
        }
    }

    void TraverseSkeleton(Transform node)
    {
        if (node == null)
        {
            return;
        }

        // 输出当前骨骼的名字
        boneNames.Add(node.name);

        // 递归遍历子节点
        for (int i = 0; i < node.childCount; i++)
        {
            TraverseSkeleton(node.GetChild(i));
        }
    }
}