Example #1
0
    public static Transform FindInChildrenByBoneEnum(Transform _root, BoneNameEnum _name)
    {
        Transform    root = _root;
        BoneNameEnum name = _name;

        foreach (Transform child in root)
        {
            BoneNamesForCharacters bnfc = child.GetComponent <BoneNamesForCharacters>();

            if (bnfc && bnfc.boneName == name)
            {
                return(child);
            }

            Transform childResult = FindInChildrenByBoneEnum(child, name);

            if (childResult)
            {
                return(childResult);
            }
        }

        return(null);
    }
    void CopyTransformByEnumName(Transform src, Transform dest)
    {
        dest.localPosition = src.localPosition;

        dest.localRotation = src.localRotation;

        dest.localScale = src.localScale;

        foreach (Transform sc in src)
        {
            BoneNamesForCharacters scBoneNameForChar = sc.GetComponent <BoneNamesForCharacters>();

            if (scBoneNameForChar)
            {
                foreach (BoneNamesForCharacters charBoneName in allBoneNames)
                {
                    if (scBoneNameForChar.boneName == charBoneName.boneName)
                    {
                        CopyTransformByEnumName(sc, charBoneName.transform);
                    }
                }
            }
        }
    }