コード例 #1
0
        protected BoneState GetBoneState(int i, out string error)
        {
            error = string.Empty;
            AvatarSetupTool.BoneWrapper bone = this.m_Bones[i];
            if (bone.bone == null)
            {
                return(BoneState.None);
            }
            AvatarSetupTool.BoneWrapper boneWrapper = this.m_Bones[AvatarSetupTool.GetFirstHumanBoneAncestor(this.m_Bones, i)];
            if (i == 0 && bone.bone.parent == null)
            {
                error = bone.messageName + " cannot be the root transform";
                return(BoneState.InvalidHierarchy);
            }
            if (boneWrapper.bone != null && !bone.bone.IsChildOf(boneWrapper.bone))
            {
                error = bone.messageName + " is not a child of " + boneWrapper.messageName + ".";
                return(BoneState.InvalidHierarchy);
            }
            if (i != 23 && boneWrapper.bone != null && boneWrapper.bone != bone.bone && (bone.bone.position - boneWrapper.bone.position).sqrMagnitude < Mathf.Epsilon)
            {
                error = bone.messageName + " has bone length of zero.";
                return(BoneState.BoneLenghtIsZero);
            }
            IEnumerable <AvatarSetupTool.BoneWrapper> source =
                from f in this.m_Bones
                where f.bone == bone.bone
                select f;

            if (source.Count <AvatarSetupTool.BoneWrapper>() > 1)
            {
                error = bone.messageName + " is also assigned to ";
                bool flag = true;
                for (int j = 0; j < this.m_Bones.Length; j++)
                {
                    if (i != j && this.m_Bones[i].bone == this.m_Bones[j].bone)
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        else
                        {
                            error += ", ";
                        }
                        error += ObjectNames.NicifyVariableName(this.m_Bones[j].humanBoneName);
                    }
                }
                error += ".";
                return(BoneState.Duplicate);
            }
            return(BoneState.Valid);
        }
コード例 #2
0
        protected BoneState GetBoneState(int i, out string error)
        {
            error = string.Empty;
            AvatarSetupTool.BoneWrapper bone = m_Bones[i];

            if (bone.bone == null)
            {
                return(BoneState.None);
            }

            int ancestorIndex = AvatarSetupTool.GetFirstHumanBoneAncestor(m_Bones, i);

            AvatarSetupTool.BoneWrapper ancestor = m_Bones[ancestorIndex > 0 ? ancestorIndex : 0];

            if (i == 0 && bone.bone.parent == null)
            {
                error = bone.messageName + " cannot be the root transform";
                return(BoneState.InvalidHierarchy);
            }

            if (ancestor.bone != null && !bone.bone.IsChildOf(ancestor.bone))
            {
                error = bone.messageName + " is not a child of " + ancestor.messageName + ".";
                return(BoneState.InvalidHierarchy);
            }

            if (i == (int)HumanBodyBones.UpperChest)
            {
                AvatarSetupTool.BoneWrapper chest = m_Bones[(int)HumanBodyBones.Chest];

                if (chest.bone == null)
                {
                    error = "Chest must be assigned before assigning UpperChest.";
                    return(BoneState.InvalidHierarchy);
                }
            }

            // Hips bone is a special case, for hips GetFirstAnscestor return hips
            if (i != (int)HumanBodyBones.Jaw && ancestor.bone != null && ancestor.bone != bone.bone && (bone.bone.position - ancestor.bone.position).sqrMagnitude < Mathf.Epsilon)
            {
                error = bone.messageName + " has bone length of zero.";
                return(BoneState.BoneLenghtIsZero);
            }

            // Does this transfrom is already set
            //List<BoneWrapper> match = ArrayUtility.FindAll (m_BoneWrappers, delegate (Transform t) { return t == m_BoneWrappers[i].bone; });
            IEnumerable <AvatarSetupTool.BoneWrapper> match = m_Bones.Where(f => f.bone == bone.bone);

            // when we search in the list we must add 1 because the bone is in this list
            if (match.Count() > 1)
            {
                error = bone.messageName + " is also assigned to ";
                bool first = true;
                for (int j = 0; j < m_Bones.Length; j++)
                {
                    if (i != j && m_Bones[i].bone == m_Bones[j].bone)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            error += ", ";
                        }
                        error += ObjectNames.NicifyVariableName(m_Bones[j].humanBoneName);
                    }
                }
                error += ".";
                return(BoneState.Duplicate);
            }
            else
            {
                return(BoneState.Valid);
            }
        }
コード例 #3
0
        protected BoneState GetBoneState(int i, out string error)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AvatarMappingEditor.\u003CGetBoneState\u003Ec__AnonStorey9D stateCAnonStorey9D = new AvatarMappingEditor.\u003CGetBoneState\u003Ec__AnonStorey9D();
            error = string.Empty;
            // ISSUE: reference to a compiler-generated field
            stateCAnonStorey9D.bone = this.m_Bones[i];
            // ISSUE: reference to a compiler-generated field
            if ((UnityEngine.Object)stateCAnonStorey9D.bone.bone == (UnityEngine.Object)null)
            {
                return(BoneState.None);
            }
            AvatarSetupTool.BoneWrapper bone = this.m_Bones[AvatarSetupTool.GetFirstHumanBoneAncestor(this.m_Bones, i)];
            // ISSUE: reference to a compiler-generated field
            if (i == 0 && (UnityEngine.Object)stateCAnonStorey9D.bone.bone.parent == (UnityEngine.Object)null)
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " cannot be the root transform";
                return(BoneState.InvalidHierarchy);
            }
            // ISSUE: reference to a compiler-generated field
            if ((UnityEngine.Object)bone.bone != (UnityEngine.Object)null && !stateCAnonStorey9D.bone.bone.IsChildOf(bone.bone))
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " is not a child of " + bone.messageName + ".";
                return(BoneState.InvalidHierarchy);
            }
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            if (i != 23 && (UnityEngine.Object)bone.bone != (UnityEngine.Object)null && (UnityEngine.Object)bone.bone != (UnityEngine.Object)stateCAnonStorey9D.bone.bone && (double)(stateCAnonStorey9D.bone.bone.position - bone.bone.position).sqrMagnitude < (double)Mathf.Epsilon)
            {
                // ISSUE: reference to a compiler-generated field
                error = stateCAnonStorey9D.bone.messageName + " has bone length of zero.";
                return(BoneState.BoneLenghtIsZero);
            }
            // ISSUE: reference to a compiler-generated method
            if (((IEnumerable <AvatarSetupTool.BoneWrapper>) this.m_Bones).Where <AvatarSetupTool.BoneWrapper>(new Func <AvatarSetupTool.BoneWrapper, bool>(stateCAnonStorey9D.\u003C\u003Em__1CA)).Count <AvatarSetupTool.BoneWrapper>() <= 1)
            {
                return(BoneState.Valid);
            }
            // ISSUE: reference to a compiler-generated field
            error = stateCAnonStorey9D.bone.messageName + " is also assigned to ";
            bool flag = true;

            for (int index = 0; index < this.m_Bones.Length; ++index)
            {
                if (i != index && (UnityEngine.Object) this.m_Bones[i].bone == (UnityEngine.Object) this.m_Bones[index].bone)
                {
                    if (flag)
                    {
                        flag = false;
                    }
                    else
                    {
                        error = error + ", ";
                    }
                    error = error + ObjectNames.NicifyVariableName(this.m_Bones[index].humanBoneName);
                }
            }
            error = error + ".";
            return(BoneState.Duplicate);
        }