private static DrawSkeletonSubTree ( bool>.Dictionary |
||
actualBones | bool>.Dictionary | |
bones | AvatarSetupTool | |
orientation | ||
tr | ||
bounds | ||
return | bool |
private static bool DrawSkeletonSubTree(Dictionary <Transform, bool> actualBones, AvatarSetupTool.BoneWrapper[] bones, Quaternion orientation, Transform tr, Bounds bounds) { if (!actualBones.ContainsKey(tr)) { return(false); } int num = 0; foreach (Transform tr2 in tr) { if (AvatarSkeletonDrawer.DrawSkeletonSubTree(actualBones, bones, orientation, tr2, bounds)) { num++; } } if (!actualBones[tr] && num <= 1) { return(false); } int num2 = -1; if (bones != null) { for (int i = 0; i < bones.Length; i++) { if (bones[i].bone == tr) { num2 = i; break; } } } bool flag = AvatarSetupTool.GetBoneAlignmentError(bones, orientation, num2) > 0f; AvatarSkeletonDrawer.sPoseError |= flag; if (flag) { AvatarSkeletonDrawer.DrawPoseError(tr, bounds); Handles.color = AvatarSkeletonDrawer.kErrorColor; } else if (num2 != -1) { Handles.color = AvatarSkeletonDrawer.kHumanColor; } else if (!actualBones[tr]) { Handles.color = AvatarSkeletonDrawer.kDummyColor; } else { Handles.color = AvatarSkeletonDrawer.kSkeletonColor; } Handles.DoBoneHandle(tr, actualBones); if (Selection.activeObject == tr) { Handles.color = AvatarSkeletonDrawer.kSelectedColor; Handles.DoBoneHandle(tr, actualBones); } return(true); }
private static bool DrawSkeletonSubTree(Dictionary <Transform, bool> actualBones, AvatarSetupTool.BoneWrapper[] bones, Quaternion orientation, Transform tr, Bounds bounds) { if (!actualBones.ContainsKey(tr)) { return(false); } int num = 0; foreach (Transform tr1 in tr) { if (AvatarSkeletonDrawer.DrawSkeletonSubTree(actualBones, bones, orientation, tr1, bounds)) { ++num; } } if (!actualBones[tr] && num <= 1) { return(false); } int boneIndex = -1; if (bones != null) { for (int index = 0; index < bones.Length; ++index) { if ((Object)bones[index].bone == (Object)tr) { boneIndex = index; break; } } } bool flag = (double)AvatarSetupTool.GetBoneAlignmentError(bones, orientation, boneIndex) > 0.0; AvatarSkeletonDrawer.sPoseError |= flag; if (flag) { AvatarSkeletonDrawer.DrawPoseError(tr, bounds); Handles.color = AvatarSkeletonDrawer.kErrorColor; } else { Handles.color = boneIndex == -1 ? (actualBones[tr] ? AvatarSkeletonDrawer.kSkeletonColor : AvatarSkeletonDrawer.kDummyColor) : AvatarSkeletonDrawer.kHumanColor; } Handles.DoBoneHandle(tr, actualBones); if (Selection.activeObject == (Object)tr) { Handles.color = AvatarSkeletonDrawer.kSelectedColor; Handles.DoBoneHandle(tr, actualBones); } return(true); }
public static void DrawSkeleton(Transform reference, Dictionary <Transform, bool> actualBones, AvatarSetupTool.BoneWrapper[] bones) { if ((Object)reference == (Object)null || actualBones == null) { return; } AvatarSkeletonDrawer.sPoseError = false; Bounds bounds = new Bounds(); Renderer[] componentsInChildren = reference.root.GetComponentsInChildren <Renderer>(); if (componentsInChildren != null) { foreach (Renderer renderer in componentsInChildren) { bounds.Encapsulate(renderer.bounds.min); bounds.Encapsulate(renderer.bounds.max); } } Quaternion orientation = Quaternion.identity; if (bones != null) { orientation = AvatarSetupTool.AvatarComputeOrientation(bones); } AvatarSkeletonDrawer.DrawSkeletonSubTree(actualBones, bones, orientation, reference, bounds); Camera current = Camera.current; if (!AvatarSkeletonDrawer.sPoseError || !((Object)current != (Object)null)) { return; } GUIStyle style = new GUIStyle(GUI.skin.label); style.normal.textColor = Color.red; style.wordWrap = false; style.alignment = TextAnchor.MiddleLeft; style.fontSize = 20; GUIContent content = new GUIContent("Character is not in T pose"); Rect rect = GUILayoutUtility.GetRect(content, style); rect.x = 30f; rect.y = 30f; Handles.BeginGUI(); GUI.Label(rect, content, style); Handles.EndGUI(); }
public static void DrawSkeleton(Transform reference, Dictionary <Transform, bool> actualBones, AvatarSetupTool.BoneWrapper[] bones) { if (!(reference == null) && actualBones != null) { AvatarSkeletonDrawer.sPoseError = false; Bounds bounds = default(Bounds); Renderer[] componentsInChildren = reference.root.GetComponentsInChildren <Renderer>(); if (componentsInChildren != null) { Renderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Renderer renderer = array[i]; bounds.Encapsulate(renderer.bounds.min); bounds.Encapsulate(renderer.bounds.max); } } Quaternion orientation = Quaternion.identity; if (bones != null) { orientation = AvatarSetupTool.AvatarComputeOrientation(bones); } AvatarSkeletonDrawer.DrawSkeletonSubTree(actualBones, bones, orientation, reference, bounds); Camera current = Camera.current; if (AvatarSkeletonDrawer.sPoseError && current != null) { GUIStyle gUIStyle = new GUIStyle(GUI.skin.label); gUIStyle.normal.textColor = Color.red; gUIStyle.wordWrap = false; gUIStyle.alignment = TextAnchor.MiddleLeft; gUIStyle.fontSize = 20; GUIContent content = new GUIContent("Character is not in T pose"); Rect rect = GUILayoutUtility.GetRect(content, gUIStyle); rect.x = 30f; rect.y = 30f; Handles.BeginGUI(); GUI.Label(rect, content, gUIStyle); Handles.EndGUI(); } } }
private static bool DrawSkeletonSubTree(Dictionary <Transform, bool> actualBones, AvatarSetupTool.BoneWrapper[] bones, Quaternion orientation, Transform tr, Bounds bounds) { bool result; if (!actualBones.ContainsKey(tr)) { result = false; } else { int num = 0; IEnumerator enumerator = tr.GetEnumerator(); try { while (enumerator.MoveNext()) { Transform tr2 = (Transform)enumerator.Current; if (AvatarSkeletonDrawer.DrawSkeletonSubTree(actualBones, bones, orientation, tr2, bounds)) { num++; } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } if (!actualBones[tr] && num <= 1) { result = false; } else { int num2 = -1; if (bones != null) { for (int i = 0; i < bones.Length; i++) { if (bones[i].bone == tr) { num2 = i; break; } } } bool flag = AvatarSetupTool.GetBoneAlignmentError(bones, orientation, num2) > 0f; AvatarSkeletonDrawer.sPoseError |= flag; if (flag) { AvatarSkeletonDrawer.DrawPoseError(tr, bounds); Handles.color = AvatarSkeletonDrawer.kErrorColor; } else if (num2 != -1) { Handles.color = AvatarSkeletonDrawer.kHumanColor; } else if (!actualBones[tr]) { Handles.color = AvatarSkeletonDrawer.kDummyColor; } else { Handles.color = AvatarSkeletonDrawer.kSkeletonColor; } Handles.DoBoneHandle(tr, actualBones); if (Selection.activeObject == tr) { Handles.color = AvatarSkeletonDrawer.kSelectedColor; Handles.DoBoneHandle(tr, actualBones); } result = true; } } return(result); }