UnityEditor.AvatarBipedMapper.MapBipedBone C# (CSharp) Method

MapBipedBone() private static method

private static MapBipedBone ( int boneIndex, Transform transform, Transform parentTransform, List report ) : Transform
boneIndex int
transform UnityEngine.Transform
parentTransform UnityEngine.Transform
report List
return UnityEngine.Transform
        private static Transform MapBipedBone(int boneIndex, Transform transform, Transform parentTransform, List<string> report)
        {
            Transform child = null;
            if (transform != null)
            {
                int childCount = transform.childCount;
                for (int i = 0; (child == null) && (i < childCount); i++)
                {
                    if (transform.GetChild(i).name.EndsWith(kBipedHumanBoneNames[boneIndex]))
                    {
                        child = transform.GetChild(i);
                        if (((child != null) && (report != null)) && ((boneIndex != 0) && (transform != parentTransform)))
                        {
                            string[] textArray1 = new string[] { "- Invalid parent for ", child.name, ".Expected ", parentTransform.name, ", but found ", transform.name, "." };
                            string item = string.Concat(textArray1);
                            if ((boneIndex == 1) || (boneIndex == 2))
                            {
                                item = item + " Disable Triangle Pelvis";
                            }
                            else if ((boneIndex == 11) || (boneIndex == 12))
                            {
                                item = item + " Enable Triangle Neck";
                            }
                            else if (boneIndex == 9)
                            {
                                item = item + " Preferred is two Spine Links";
                            }
                            else if (boneIndex == 10)
                            {
                                item = item + " Preferred is one Neck Links";
                            }
                            item = item + "\n";
                            report.Add(item);
                        }
                    }
                }
                for (int j = 0; (child == null) && (j < childCount); j++)
                {
                    child = MapBipedBone(boneIndex, transform.GetChild(j), parentTransform, report);
                }
            }
            return child;
        }

Usage Example

Beispiel #1
0
        private static bool MapBipedBones(Transform root, ref Transform[] humanToTransform, List <string> report)
        {
            bool result;

            for (int i = 0; i < AvatarBipedMapper.s_BipedBones.Length; i++)
            {
                int       index      = AvatarBipedMapper.s_BipedBones[i].index;
                int       parentBone = HumanTrait.GetParentBone(index);
                bool      flag       = HumanTrait.RequiredBone(index);
                bool      flag2      = parentBone == -1 || HumanTrait.RequiredBone(parentBone);
                Transform transform  = (parentBone == -1) ? root : humanToTransform[parentBone];
                if (transform == null && !flag2)
                {
                    parentBone = HumanTrait.GetParentBone(parentBone);
                    flag2      = (parentBone == -1 || HumanTrait.RequiredBone(parentBone));
                    transform  = ((parentBone == -1) ? null : humanToTransform[parentBone]);
                    if (transform == null && !flag2)
                    {
                        parentBone = HumanTrait.GetParentBone(parentBone);
                        transform  = ((parentBone == -1) ? null : humanToTransform[parentBone]);
                    }
                }
                humanToTransform[index] = AvatarBipedMapper.MapBipedBone(i, transform, transform, report);
                if (humanToTransform[index] == null && flag)
                {
                    result = false;
                    return(result);
                }
            }
            result = true;
            return(result);
        }
All Usage Examples Of UnityEditor.AvatarBipedMapper::MapBipedBone