public void MaskFromClip(AvatarMask mask) { SerializedProperty serializedProperty1 = this.Get("bodyMask"); if (serializedProperty1 != null && serializedProperty1.isArray) { for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart; ++index) { mask.SetHumanoidBodyPartActive(index, serializedProperty1.GetArrayElementAtIndex((int)index).intValue != 0); } } SerializedProperty serializedProperty2 = this.Get("transformMask"); if (serializedProperty2 == null || !serializedProperty2.isArray) { return; } if (serializedProperty2.arraySize > 0 && mask.transformCount != serializedProperty2.arraySize) { mask.transformCount = serializedProperty2.arraySize; } int arraySize = serializedProperty2.arraySize; for (int index = 0; index < arraySize; ++index) { SerializedProperty propertyRelative1 = serializedProperty2.GetArrayElementAtIndex(index).FindPropertyRelative("m_Path"); SerializedProperty propertyRelative2 = serializedProperty2.GetArrayElementAtIndex(index).FindPropertyRelative("m_Weight"); mask.SetTransformPath(index, propertyRelative1.stringValue); mask.SetTransformActive(index, (double)propertyRelative2.floatValue > 0.5); } }
public void MaskFromClip(AvatarMask mask) { SerializedProperty serializedProperty = this.Get("bodyMask"); if (serializedProperty != null && serializedProperty.isArray) { for (AvatarMaskBodyPart avatarMaskBodyPart = AvatarMaskBodyPart.Root; avatarMaskBodyPart < AvatarMaskBodyPart.LastBodyPart; avatarMaskBodyPart++) { mask.SetHumanoidBodyPartActive(avatarMaskBodyPart, serializedProperty.GetArrayElementAtIndex((int)avatarMaskBodyPart).intValue != 0); } } SerializedProperty serializedProperty2 = this.Get("transformMask"); if (serializedProperty2 != null && serializedProperty2.isArray) { if (serializedProperty2.arraySize > 0 && mask.transformCount != serializedProperty2.arraySize) { mask.transformCount = serializedProperty2.arraySize; } int arraySize = serializedProperty2.arraySize; if (arraySize == 0) { return; } SerializedProperty arrayElementAtIndex = serializedProperty2.GetArrayElementAtIndex(0); for (int i = 0; i < arraySize; i++) { SerializedProperty serializedProperty3 = arrayElementAtIndex.FindPropertyRelative("m_Path"); SerializedProperty serializedProperty4 = arrayElementAtIndex.FindPropertyRelative("m_Weight"); mask.SetTransformPath(i, serializedProperty3.stringValue); mask.SetTransformActive(i, (double)serializedProperty4.floatValue > 0.5); arrayElementAtIndex.Next(false); } } }
public void MaskFromClip(AvatarMask mask) { SerializedProperty property = this.Get("bodyMask"); if ((property != null) && property.isArray) { for (AvatarMaskBodyPart part = AvatarMaskBodyPart.Root; part < AvatarMaskBodyPart.LastBodyPart; part += 1) { mask.SetHumanoidBodyPartActive(part, property.GetArrayElementAtIndex((int)part).intValue != 0); } } SerializedProperty property2 = this.Get("transformMask"); if ((property2 != null) && property2.isArray) { if ((property2.arraySize > 0) && (mask.transformCount != property2.arraySize)) { mask.transformCount = property2.arraySize; } int arraySize = property2.arraySize; for (int i = 0; i < arraySize; i++) { SerializedProperty property3 = property2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Path"); SerializedProperty property4 = property2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Weight"); mask.SetTransformPath(i, property3.stringValue); mask.SetTransformActive(i, property4.floatValue > 0.5); } } }
public bool MaskNeedsUpdating() { AvatarMask maskSource = this.maskSource; bool result; if (maskSource == null) { result = false; } else { SerializedProperty serializedProperty = this.Get("bodyMask"); if (serializedProperty != null && serializedProperty.isArray) { for (AvatarMaskBodyPart avatarMaskBodyPart = AvatarMaskBodyPart.Root; avatarMaskBodyPart < AvatarMaskBodyPart.LastBodyPart; avatarMaskBodyPart++) { if (maskSource.GetHumanoidBodyPartActive(avatarMaskBodyPart) != (serializedProperty.GetArrayElementAtIndex((int)avatarMaskBodyPart).intValue != 0)) { result = true; return(result); } } SerializedProperty serializedProperty2 = this.Get("transformMask"); if (serializedProperty2 != null && serializedProperty2.isArray) { if (serializedProperty2.arraySize > 0 && maskSource.transformCount != serializedProperty2.arraySize) { result = true; } else { int arraySize = serializedProperty2.arraySize; for (int i = 0; i < arraySize; i++) { SerializedProperty serializedProperty3 = serializedProperty2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Path"); SerializedProperty serializedProperty4 = serializedProperty2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Weight"); if (maskSource.GetTransformPath(i) != serializedProperty3.stringValue || maskSource.GetTransformActive(i) != serializedProperty4.floatValue > 0.5f) { result = true; return(result); } } result = false; } } else { result = true; } } else { result = true; } } return(result); }
public bool MaskNeedsUpdating() { AvatarMask mask = maskSource; if (mask == null) { return(false); } SerializedProperty bodyMask = Get("bodyMask"); if (bodyMask != null && bodyMask.isArray) { for (AvatarMaskBodyPart i = 0; i < AvatarMaskBodyPart.LastBodyPart; i++) { if (mask.GetHumanoidBodyPartActive(i) != (bodyMask.GetArrayElementAtIndex((int)i).intValue != 0)) { return(true); } } } else { return(true); } SerializedProperty transformMask = Get("transformMask"); if (transformMask != null && transformMask.isArray) { if (transformMask.arraySize > 0 && (mask.transformCount != transformMask.arraySize)) { return(true); } int size = transformMask.arraySize; for (int i = 0; i < size; i++) { SerializedProperty pathProperty = transformMask.GetArrayElementAtIndex(i).FindPropertyRelative("m_Path"); SerializedProperty weightProperty = transformMask.GetArrayElementAtIndex(i).FindPropertyRelative("m_Weight"); if (mask.GetTransformPath(i) != pathProperty.stringValue || mask.GetTransformActive(i) != (weightProperty.floatValue > 0.5f)) { return(true); } } } else { return(true); } return(false); }
internal void Copy(AvatarMask other) { for (AvatarMaskBodyPart avatarMaskBodyPart = AvatarMaskBodyPart.Root; avatarMaskBodyPart < AvatarMaskBodyPart.LastBodyPart; avatarMaskBodyPart++) { SetHumanoidBodyPartActive(avatarMaskBodyPart, other.GetHumanoidBodyPartActive(avatarMaskBodyPart)); } transformCount = other.transformCount; for (int i = 0; i < other.transformCount; i++) { SetTransformPath(i, other.GetTransformPath(i)); SetTransformActive(i, other.GetTransformActive(i)); } }
internal void Copy(AvatarMask other) { for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart; ++index) { this.SetHumanoidBodyPartActive(index, other.GetHumanoidBodyPartActive(index)); } this.transformCount = other.transformCount; for (int index = 0; index < other.transformCount; ++index) { this.SetTransformPath(index, other.GetTransformPath(index)); this.SetTransformActive(index, other.GetTransformActive(index)); } }
public bool MaskNeedsUpdating() { AvatarMask maskSource = this.maskSource; if (maskSource != null) { SerializedProperty property = this.Get("bodyMask"); if ((property != null) && property.isArray) { for (AvatarMaskBodyPart part = AvatarMaskBodyPart.Root; part < AvatarMaskBodyPart.LastBodyPart; part += 1) { if (maskSource.GetHumanoidBodyPartActive(part) != (property.GetArrayElementAtIndex((int)part).intValue != 0)) { return(true); } } } else { return(true); } SerializedProperty property2 = this.Get("transformMask"); if ((property2 != null) && property2.isArray) { if ((property2.arraySize > 0) && (maskSource.transformCount != property2.arraySize)) { return(true); } int arraySize = property2.arraySize; for (int i = 0; i < arraySize; i++) { SerializedProperty property3 = property2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Path"); SerializedProperty property4 = property2.GetArrayElementAtIndex(i).FindPropertyRelative("m_Weight"); if ((maskSource.GetTransformPath(i) != property3.stringValue) || (maskSource.GetTransformActive(i) != (property4.floatValue > 0.5f))) { return(true); } } } else { return(true); } } return(false); }
public void MaskToClip(AvatarMask mask) { SerializedProperty property = this.Get("bodyMask"); if ((property != null) && property.isArray) { for (AvatarMaskBodyPart part = AvatarMaskBodyPart.Root; part < AvatarMaskBodyPart.LastBodyPart; part += 1) { if (part >= property.arraySize) { property.InsertArrayElementAtIndex((int)part); } property.GetArrayElementAtIndex((int)part).intValue = !mask.GetHumanoidBodyPartActive(part) ? 0 : 1; } } SerializedProperty serializedProperty = this.Get("transformMask"); ModelImporter.UpdateTransformMask(mask, serializedProperty); }
public void MaskToClip(AvatarMask mask) { SerializedProperty serializedProperty = this.Get("bodyMask"); if (serializedProperty != null && serializedProperty.isArray) { for (AvatarMaskBodyPart avatarMaskBodyPart = AvatarMaskBodyPart.Root; avatarMaskBodyPart < AvatarMaskBodyPart.LastBodyPart; avatarMaskBodyPart++) { if (avatarMaskBodyPart >= (AvatarMaskBodyPart)serializedProperty.arraySize) { serializedProperty.InsertArrayElementAtIndex((int)avatarMaskBodyPart); } serializedProperty.GetArrayElementAtIndex((int)avatarMaskBodyPart).intValue = ((!mask.GetHumanoidBodyPartActive(avatarMaskBodyPart)) ? 0 : 1); } } SerializedProperty serializedProperty2 = this.Get("transformMask"); ModelImporter.UpdateTransformMask(mask, serializedProperty2); }
public void MaskToClip(AvatarMask mask) { SerializedProperty serializedProperty1 = this.Get("bodyMask"); if (serializedProperty1 != null && serializedProperty1.isArray) { for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart; ++index) { if (index >= (AvatarMaskBodyPart)serializedProperty1.arraySize) { serializedProperty1.InsertArrayElementAtIndex((int)index); } serializedProperty1.GetArrayElementAtIndex((int)index).intValue = !mask.GetHumanoidBodyPartActive(index) ? 0 : 1; } } SerializedProperty serializedProperty2 = this.Get("transformMask"); ModelImporter.UpdateTransformMask(mask, serializedProperty2); }
public void MaskToClip(AvatarMask mask) { SerializedProperty bodyMask = Get("bodyMask"); if (bodyMask != null && bodyMask.isArray) { for (AvatarMaskBodyPart i = 0; i < AvatarMaskBodyPart.LastBodyPart; i++) { if ((int)i >= bodyMask.arraySize) { bodyMask.InsertArrayElementAtIndex((int)i); } bodyMask.GetArrayElementAtIndex((int)i).intValue = mask.GetHumanoidBodyPartActive(i) ? 1 : 0; } } SerializedProperty transformMask = transformMaskProperty; ModelImporter.UpdateTransformMask(mask, transformMask); }
public bool MaskNeedsUpdating() { AvatarMask maskSource = this.maskSource; if ((Object)maskSource == (Object)null) { return(false); } SerializedProperty serializedProperty1 = this.Get("bodyMask"); if (serializedProperty1 == null || !serializedProperty1.isArray) { return(true); } for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart; ++index) { if (maskSource.GetHumanoidBodyPartActive(index) != (serializedProperty1.GetArrayElementAtIndex((int)index).intValue != 0)) { return(true); } } SerializedProperty serializedProperty2 = this.Get("transformMask"); if (serializedProperty2 == null || !serializedProperty2.isArray || serializedProperty2.arraySize > 0 && maskSource.transformCount != serializedProperty2.arraySize) { return(true); } int arraySize = serializedProperty2.arraySize; for (int index = 0; index < arraySize; ++index) { SerializedProperty propertyRelative1 = serializedProperty2.GetArrayElementAtIndex(index).FindPropertyRelative("m_Path"); SerializedProperty propertyRelative2 = serializedProperty2.GetArrayElementAtIndex(index).FindPropertyRelative("m_Weight"); if (maskSource.GetTransformPath(index) != propertyRelative1.stringValue || maskSource.GetTransformActive(index) != (double)propertyRelative2.floatValue > 0.5) { return(true); } } return(false); }
public void MaskFromClip(AvatarMask mask) { SerializedProperty bodyMask = Get("bodyMask"); if (bodyMask != null && bodyMask.isArray) { for (AvatarMaskBodyPart i = 0; i < AvatarMaskBodyPart.LastBodyPart; i++) { mask.SetHumanoidBodyPartActive(i, bodyMask.GetArrayElementAtIndex((int)i).intValue != 0); } } var transformMask = transformMaskProperty; if (transformMask != null && transformMask.isArray) { if (transformMask.arraySize > 0 && (mask.transformCount != transformMask.arraySize)) { mask.transformCount = transformMask.arraySize; } int size = transformMask.arraySize; if (size == 0) { return; } SerializedProperty prop = transformMask.GetArrayElementAtIndex(0); for (int i = 0; i < size; i++) { SerializedProperty pathProperty = prop.FindPropertyRelative("m_Path"); SerializedProperty weightProperty = prop.FindPropertyRelative("m_Weight"); mask.SetTransformPath(i, pathProperty.stringValue); mask.SetTransformActive(i, weightProperty.floatValue > 0.5); prop.Next(false); } } }
private void CreateController() { if (((this.m_Controller == null) && (this.m_AvatarPreview != null)) && ((this.m_AvatarPreview.Animator != null) && (this.m_RefTransition != null))) { this.m_LayerIndex = 0; this.m_Controller = new AnimatorController(); this.m_Controller.pushUndo = false; this.m_Controller.hideFlags = HideFlags.HideAndDontSave; this.m_Controller.AddLayer("preview"); bool flag = true; if (this.m_LayerMask != null) { for (AvatarMaskBodyPart part = AvatarMaskBodyPart.Root; (part < AvatarMaskBodyPart.LastBodyPart) && flag; part += 1) { if (!this.m_LayerMask.GetHumanoidBodyPartActive(part)) { flag = false; } } if (!flag) { this.m_Controller.AddLayer("Additionnal"); this.m_LayerIndex++; AnimatorControllerLayer[] layers = this.m_Controller.layers; layers[this.m_LayerIndex].avatarMask = this.m_LayerMask; this.m_Controller.layers = layers; } } this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine; this.m_StateMachine.pushUndo = false; this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave; this.m_SrcMotion = this.m_RefSrcState.motion; this.m_DstMotion = this.m_RefDstState.motion; this.m_ParameterMinMax.Clear(); if ((this.m_SrcMotion != null) && (this.m_SrcMotion is BlendTree)) { BlendTree srcMotion = this.m_SrcMotion as BlendTree; for (int i = 0; i < srcMotion.recursiveBlendParameterCount; i++) { string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(i); if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1) { this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(i), srcMotion.GetRecursiveBlendParameterMax(i))); } } } if ((this.m_DstMotion != null) && (this.m_DstMotion is BlendTree)) { BlendTree dstMotion = this.m_DstMotion as BlendTree; for (int j = 0; j < dstMotion.recursiveBlendParameterCount; j++) { string name = dstMotion.GetRecursiveBlendParameter(j); int num3 = this.m_Controller.IndexOfParameter(name); if (num3 == -1) { this.m_Controller.AddParameter(name, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(j), dstMotion.GetRecursiveBlendParameterMax(j))); } else { Vector2 vector = this.m_ParameterMinMax[num3]; Vector2 vector2 = this.m_ParameterMinMax[num3]; this.m_ParameterMinMax[num3] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(j), vector[0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(j), vector2[1])); } } } this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name); this.m_SrcState.pushUndo = false; this.m_SrcState.hideFlags = HideFlags.HideAndDontSave; this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name); this.m_DstState.pushUndo = false; this.m_DstState.hideFlags = HideFlags.HideAndDontSave; this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState); this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState); this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true); this.m_Transition.pushUndo = false; this.m_Transition.hideFlags = HideFlags.DontSave; this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition); this.DisableIKOnFeetIfNeeded(); AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_Controller.OnAnimatorControllerDirty = (Action)Delegate.Combine(this.m_Controller.OnAnimatorControllerDirty, new Action(this.ControllerDirty)); } }
void CreateController() { if (m_Controller == null && m_AvatarPreview != null && m_AvatarPreview.Animator != null && m_RefTransition != null) { // controller m_LayerIndex = 0; m_Controller = new AnimatorController(); m_Controller.pushUndo = false; m_Controller.hideFlags = HideFlags.HideAndDontSave; m_Controller.AddLayer("preview"); bool isDefaultMask = true; if (m_LayerMask != null) { for (AvatarMaskBodyPart i = 0; i < AvatarMaskBodyPart.LastBodyPart && isDefaultMask; i++) { if (!m_LayerMask.GetHumanoidBodyPartActive(i)) { isDefaultMask = false; } } if (!isDefaultMask) { m_Controller.AddLayer("Additionnal"); m_LayerIndex++; AnimatorControllerLayer[] layers = m_Controller.layers; layers[m_LayerIndex].avatarMask = m_LayerMask; m_Controller.layers = layers; } } m_StateMachine = m_Controller.layers[m_LayerIndex].stateMachine; m_StateMachine.pushUndo = false; m_StateMachine.hideFlags = HideFlags.HideAndDontSave; m_SrcMotion = m_RefSrcState.motion; m_DstMotion = m_RefDstState.motion; /// Add parameters m_ParameterMinMax.Clear(); if (m_SrcMotion && m_SrcMotion is BlendTree) { BlendTree leftBlendTree = m_SrcMotion as BlendTree; for (int i = 0; i < leftBlendTree.recursiveBlendParameterCount; i++) { string blendValueName = leftBlendTree.GetRecursiveBlendParameter(i); if (m_Controller.IndexOfParameter(blendValueName) == -1) { m_Controller.AddParameter(blendValueName, AnimatorControllerParameterType.Float); m_ParameterMinMax.Add(new Vector2(leftBlendTree.GetRecursiveBlendParameterMin(i), leftBlendTree.GetRecursiveBlendParameterMax(i))); } } } if (m_DstMotion && m_DstMotion is BlendTree) { BlendTree rightBlendTree = m_DstMotion as BlendTree; for (int i = 0; i < rightBlendTree.recursiveBlendParameterCount; i++) { string blendValueName = rightBlendTree.GetRecursiveBlendParameter(i); int parameterIndex = m_Controller.IndexOfParameter(blendValueName); if (parameterIndex == -1) { m_Controller.AddParameter(blendValueName, AnimatorControllerParameterType.Float); m_ParameterMinMax.Add(new Vector2(rightBlendTree.GetRecursiveBlendParameterMin(i), rightBlendTree.GetRecursiveBlendParameterMax(i))); } else { m_ParameterMinMax[parameterIndex] = new Vector2(Mathf.Min(rightBlendTree.GetRecursiveBlendParameterMin(i), m_ParameterMinMax[parameterIndex][0]), Mathf.Max(rightBlendTree.GetRecursiveBlendParameterMax(i), m_ParameterMinMax[parameterIndex][1])); } } } // states m_SrcState = m_StateMachine.AddState(m_RefSrcState.name); m_SrcState.pushUndo = false; m_SrcState.hideFlags = HideFlags.HideAndDontSave; m_DstState = m_StateMachine.AddState(m_RefDstState.name); m_DstState.pushUndo = false; m_DstState.hideFlags = HideFlags.HideAndDontSave; CopyStateForPreview(m_RefSrcState, ref m_SrcState); CopyStateForPreview(m_RefDstState, ref m_DstState); // transition m_Transition = m_SrcState.AddTransition(m_DstState, true); m_Transition.pushUndo = false; m_Transition.hideFlags = HideFlags.DontSave; CopyTransitionForPreview(m_RefTransition, ref m_Transition); DisableIKOnFeetIfNeeded(); AnimatorController.SetAnimatorController(m_AvatarPreview.Animator, m_Controller); m_Controller.OnAnimatorControllerDirty += ControllerDirty; } }
void DrawPoseAdvanced() { List <nuitrack.JointType> jointsMask = NuitrackPoseWrapper.JointsMask; foreach (KeyValuePair <AvatarMaskBodyPart, SkeletonStyles.GUIBodyPart> bodyPartItem in SkeletonStyles.BodyParts) { AvatarMaskBodyPart bodyPart = bodyPartItem.Key; SkeletonStyles.GUIBodyPart guiBodyPart = bodyPartItem.Value; bool drawBodyPart = guiBodyPart.guiJoint.Any(x => jointsMask.Contains(x.JointType)); if (drawBodyPart) { EditorGUILayout.LabelField(guiBodyPart.Lable, EditorStyles.boldLabel); foreach (SkeletonStyles.GUIJoint guiJoint in guiBodyPart.guiJoint) { nuitrack.JointType jointType = guiJoint.JointType; if (jointsMask.Contains(jointType)) { NuitrackPoseWrapper.JointWrapper jointWrapper = poseWrapper[jointType]; using (new GUIColor(jointWrapper.IsActive ? GUI.color : Color.gray)) { GUIStyle contentStyle = new GUIStyle(EditorStyles.helpBox) { margin = new RectOffset(20, 0, 2, 2) }; Color selectColor = SelectedJoint == jointType ? colorTheme.mainColor : GUI.color; using (new VerticalGroup(contentStyle, null, selectColor)) { string displayName = NuitrackSDKGUI.GetUnityDisplayBoneName(jointType.ToUnityBones(), bodyPart); if (!jointWrapper.IsActive) { displayName += " (disabled)"; } bool isActive = EditorGUILayout.ToggleLeft(displayName, jointWrapper.IsActive, EditorStyles.boldLabel); if (isActive != jointWrapper.IsActive) { if (jointWrapper.IsActive && jointType == SelectedJoint) { SelectedJoint = nuitrack.JointType.None; } jointWrapper.IsActive = isActive; } if (isActive) { //jointWrapper.Orientation = Quaternion.Euler(EditorGUILayout.Vector3Field("", jointWrapper.Orientation.eulerAngles)); jointWrapper.Tolerance = EditorGUILayout.Slider("Tolerance", jointWrapper.Tolerance, 0.1f, 0.98f); } } } } } } } }
public extern void SetHumanoidBodyPartActive(AvatarMaskBodyPart index, bool value);
private void CreateController() { if (this.m_Controller == null && this.m_AvatarPreview != null && this.m_AvatarPreview.Animator != null && this.m_RefTransition != null) { this.m_LayerIndex = 0; this.m_Controller = new AnimatorController(); this.m_Controller.pushUndo = false; this.m_Controller.hideFlags = HideFlags.HideAndDontSave; this.m_Controller.AddLayer("preview"); bool flag = true; if (this.m_LayerMask != null) { AvatarMaskBodyPart avatarMaskBodyPart = AvatarMaskBodyPart.Root; while (avatarMaskBodyPart < AvatarMaskBodyPart.LastBodyPart && flag) { if (!this.m_LayerMask.GetHumanoidBodyPartActive(avatarMaskBodyPart)) { flag = false; } avatarMaskBodyPart++; } if (!flag) { this.m_Controller.AddLayer("Additionnal"); this.m_LayerIndex++; AnimatorControllerLayer[] layers = this.m_Controller.layers; layers[this.m_LayerIndex].avatarMask = this.m_LayerMask; this.m_Controller.layers = layers; } } this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine; this.m_StateMachine.pushUndo = false; this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave; this.m_SrcMotion = this.m_RefSrcState.motion; this.m_DstMotion = this.m_RefDstState.motion; this.m_ParameterMinMax.Clear(); if (this.m_SrcMotion && this.m_SrcMotion is BlendTree) { BlendTree blendTree = this.m_SrcMotion as BlendTree; for (int i = 0; i < blendTree.recursiveBlendParameterCount; i++) { string recursiveBlendParameter = blendTree.GetRecursiveBlendParameter(i); if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1) { this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(blendTree.GetRecursiveBlendParameterMin(i), blendTree.GetRecursiveBlendParameterMax(i))); } } } if (this.m_DstMotion && this.m_DstMotion is BlendTree) { BlendTree blendTree2 = this.m_DstMotion as BlendTree; for (int j = 0; j < blendTree2.recursiveBlendParameterCount; j++) { string recursiveBlendParameter2 = blendTree2.GetRecursiveBlendParameter(j); int num = this.m_Controller.IndexOfParameter(recursiveBlendParameter2); if (num == -1) { this.m_Controller.AddParameter(recursiveBlendParameter2, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(blendTree2.GetRecursiveBlendParameterMin(j), blendTree2.GetRecursiveBlendParameterMax(j))); } else { this.m_ParameterMinMax[num] = new Vector2(Mathf.Min(blendTree2.GetRecursiveBlendParameterMin(j), this.m_ParameterMinMax[num][0]), Mathf.Max(blendTree2.GetRecursiveBlendParameterMax(j), this.m_ParameterMinMax[num][1])); } } } this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name); this.m_SrcState.pushUndo = false; this.m_SrcState.hideFlags = HideFlags.HideAndDontSave; this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name); this.m_DstState.pushUndo = false; this.m_DstState.hideFlags = HideFlags.HideAndDontSave; this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState); this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState); this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true); this.m_Transition.pushUndo = false; this.m_Transition.hideFlags = HideFlags.DontSave; this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition); this.DisableIKOnFeetIfNeeded(); AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); AnimatorController expr_404 = this.m_Controller; expr_404.OnAnimatorControllerDirty = (Action)Delegate.Combine(expr_404.OnAnimatorControllerDirty, new Action(this.ControllerDirty)); } }
public extern bool GetHumanoidBodyPartActive(AvatarMaskBodyPart index);
public bool GetHumanoidBodyPartActive(AvatarMaskBodyPart index);
private void CreateController() { if (!((UnityEngine.Object) this.m_Controller == (UnityEngine.Object)null) || this.m_AvatarPreview == null || (!((UnityEngine.Object) this.m_AvatarPreview.Animator != (UnityEngine.Object)null) || !((UnityEngine.Object) this.m_RefTransition != (UnityEngine.Object)null))) { return; } this.m_LayerIndex = 0; this.m_Controller = new AnimatorController(); this.m_Controller.pushUndo = false; this.m_Controller.hideFlags = HideFlags.HideAndDontSave; this.m_Controller.AddLayer("preview"); bool flag = true; if ((UnityEngine.Object) this.m_LayerMask != (UnityEngine.Object)null) { for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart && flag; ++index) { if (!this.m_LayerMask.GetHumanoidBodyPartActive(index)) { flag = false; } } if (!flag) { this.m_Controller.AddLayer("Additionnal"); ++this.m_LayerIndex; AnimatorControllerLayer[] layers = this.m_Controller.layers; layers[this.m_LayerIndex].avatarMask = this.m_LayerMask; this.m_Controller.layers = layers; } } this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine; this.m_StateMachine.pushUndo = false; this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave; this.m_SrcMotion = this.m_RefSrcState.motion; this.m_DstMotion = this.m_RefDstState.motion; this.m_ParameterMinMax.Clear(); if ((bool)((UnityEngine.Object) this.m_SrcMotion) && this.m_SrcMotion is BlendTree) { BlendTree srcMotion = this.m_SrcMotion as BlendTree; for (int index = 0; index < srcMotion.recursiveBlendParameterCount; ++index) { string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(index); if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1) { this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(index), srcMotion.GetRecursiveBlendParameterMax(index))); } } } if ((bool)((UnityEngine.Object) this.m_DstMotion) && this.m_DstMotion is BlendTree) { BlendTree dstMotion = this.m_DstMotion as BlendTree; for (int index1 = 0; index1 < dstMotion.recursiveBlendParameterCount; ++index1) { string recursiveBlendParameter = dstMotion.GetRecursiveBlendParameter(index1); int index2 = this.m_Controller.IndexOfParameter(recursiveBlendParameter); if (index2 == -1) { this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float); this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(index1), dstMotion.GetRecursiveBlendParameterMax(index1))); } else { this.m_ParameterMinMax[index2] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(index1), this.m_ParameterMinMax[index2][0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(index1), this.m_ParameterMinMax[index2][1])); } } } this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name); this.m_SrcState.pushUndo = false; this.m_SrcState.hideFlags = HideFlags.HideAndDontSave; this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name); this.m_DstState.pushUndo = false; this.m_DstState.hideFlags = HideFlags.HideAndDontSave; this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState); this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState); this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true); this.m_Transition.pushUndo = false; this.m_Transition.hideFlags = HideFlags.DontSave; this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition); this.DisableIKOnFeetIfNeeded(); AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_Controller.OnAnimatorControllerDirty += new System.Action(this.ControllerDirty); }
/// <summary> /// Draw a map of joints /// </summary> /// <param name="activeJoints">Active joints (will be displayed as filled dots)</param> public void Draw(List <JointType> activeJoints) { Rect rect = GUILayoutUtility.GetRect(SkeletonStyles.UnityDude, GUIStyle.none, GUILayout.MaxWidth(SkeletonStyles.UnityDude.image.width)); rect.x += (EditorGUIUtility.currentViewWidth - rect.width) / 2; Color grayColor = new Color(0.2f, 0.2f, 0.2f, 1.0f); using (new GUIColor(grayColor)) GUI.DrawTexture(rect, SkeletonStyles.UnityDude.image); GUIStyle centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")) { alignment = TextAnchor.UpperCenter, fontStyle = FontStyle.Bold }; foreach (KeyValuePair <GUIContent, Vector2> labelData in SkeletonStyles.Labels) { Vector2 position = labelData.Value; position.Scale(rect.size); position.x -= EditorGUIUtility.labelWidth * 0.5f; Rect labelRect = new Rect(rect.center + position, new Vector2(EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight)); GUI.Label(labelRect, labelData.Key, centeredStyle); } List <AvatarMaskBodyPart> filled = GetActiveBodyParts(activeJoints); foreach (KeyValuePair <AvatarMaskBodyPart, SkeletonStyles.GUIBodyPart> bodyPart in SkeletonStyles.BodyParts) { Color partColor = filled.Contains(bodyPart.Key) ? colorTheme.mainColor : colorTheme.disableColor; using (new GUIColor(partColor)) { foreach (GUIContent guiContent in bodyPart.Value.guiContents) { GUI.DrawTexture(rect, guiContent.image); } } } foreach (KeyValuePair <AvatarMaskBodyPart, SkeletonStyles.GUIBodyPart> bodyPartItem in SkeletonStyles.BodyParts) { AvatarMaskBodyPart bodyPart = bodyPartItem.Key; SkeletonStyles.GUIBodyPart guiBodyPart = bodyPartItem.Value; foreach (SkeletonStyles.GUIJoint guiJoint in guiBodyPart.guiJoint) { JointType jointType = guiJoint.JointType; if (jointMask.Contains(jointType)) { Rect jointPointRect = DrawAvatarJointIcon(rect, guiJoint, activeJoints.Contains(jointType), jointType == SelectedJoint); int keyboardID = GUIUtility.GetControlID(FocusType.Keyboard, jointPointRect); T newJoint = HandleDragDrop(keyboardID, jointPointRect); if (newJoint != null) { OnDropAction(newJoint, jointType); } if (HandleClick(keyboardID, jointPointRect)) { OnSelectedAction(jointType); } if (HandleDelete(keyboardID)) { OnDropAction(default, jointType);
public void SetHumanoidBodyPartActive(AvatarMaskBodyPart index, bool value);