public override void OnInspectorGUI() { if (miniLabelAlignLeft == null) { miniLabelAlignLeft = new GUIStyle(EditorStyles.miniLabel); miniLabelAlignLeft.alignment = TextAnchor.UpperLeft; } if (miniLabelAlignRight == null) { miniLabelAlignRight = new GUIStyle(EditorStyles.miniLabel); miniLabelAlignRight.alignment = TextAnchor.UpperRight; } if (targets.Length == 1) { SkinDeformationClip clip = (SkinDeformationClip)target; if (clip.importSettings.solveRegionPreview) { SkinDeformationClipRegions.Enable(clip); } else { SkinDeformationClipRegions.Disable(); } EditorGUILayout.HelpBox(GetInfoString(clip), MessageType.Info, true); if (GUILayout.Button("Import")) { ImportClip(clip); } EditorGUILayout.Separator(); base.OnInspectorGUI(); EditorGUILayout.Separator(); if (GUILayout.Button("Configure Fitted Indices ...")) { GUI.FocusControl(null); var menu = new GenericMenu(); menu.AddItem(new GUIContent("Set from target mesh"), false, FittedIndices_SetFromTargetMesh, clip); menu.AddItem(new GUIContent("Set precomputed linearly independent"), false, FittedIndices_SetPrecomputed, clip); menu.AddItem(new GUIContent("Set precomputed linearly independent (wrinkles only)"), false, FittedIndices_SetPrecomputedWrinkles, clip); menu.AddItem(new GUIContent("Apply formatting and sort ascending"), false, FittedIndices_ApplyFormattingAndSortAscending, clip); menu.AddItem(new GUIContent("Apply filter to ensure linearly independent"), false, FittedIndices_ApplyFilterToEnsureLinearlyIndependent, clip); menu.ShowAsContext(); } EditorGUILayout.Separator(); framesFoldout = EditorGUILayout.Foldout(framesFoldout, "Frame intervals", EditorStyles.foldout); if (framesFoldout) { framesScroll = EditorGUILayout.BeginScrollView(framesScroll, false, true); for (int i = 0; i != clip.subframeCount; i++) { Rect rectGroup = EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel("interval " + i, EditorStyles.miniLabel); { Rect rectLabel = GUILayoutUtility.GetLastRect(); Rect rectFrame = new Rect(rectLabel); rectFrame.xMin = rectLabel.xMax; rectFrame.xMax = rectGroup.xMax; EditorGUI.DrawRect(rectFrame, Color.black); rectFrame.xMin += 1.0f; rectFrame.xMax -= 1.0f; rectFrame.yMin += 1.0f; rectFrame.yMax -= 1.0f; EditorGUI.DrawRect(rectFrame, Color.Lerp(Color.black, Color.green, 0.05f)); float x0 = rectFrame.xMin + rectFrame.width * clip.subframes[i].fractionLo; float x1 = rectFrame.xMin + rectFrame.width * clip.subframes[i].fractionHi; float y0 = clip.subframes[i].fractionLo; float y1 = clip.subframes[i].fractionHi; rectFrame.xMin = x0; rectFrame.xMax = x1; //EditorGUI.DrawRect(rectFrame, Color.Lerp(Color.black, Color.green, 0.4f)); Handles.color = Color.Lerp(Color.black, Color.green, 0.4f); Handles.DrawAAConvexPolygon( new Vector3(rectFrame.xMin, rectFrame.yMax, 0.0f), new Vector3(rectFrame.xMax, rectFrame.yMax, 0.0f), new Vector3(rectFrame.xMax, rectFrame.yMin + rectFrame.height * y1, 0.0f), new Vector3(rectFrame.xMin, rectFrame.yMin + rectFrame.height * y0, 0.0f) ); Handles.color = Color.Lerp(Color.black, Color.magenta, 0.4f); Handles.DrawAAConvexPolygon( new Vector3(rectFrame.xMin, rectFrame.yMax - rectFrame.height * (1.0f - y0), 0.0f), new Vector3(rectFrame.xMax, rectFrame.yMax - rectFrame.height * (1.0f - y1), 0.0f), new Vector3(rectFrame.xMax, rectFrame.yMin, 0.0f), new Vector3(rectFrame.xMin, rectFrame.yMin, 0.0f) ); } EditorGUILayout.TextField("keyframe " + clip.subframes[i].frameIndexLo, miniLabelAlignLeft); EditorGUILayout.TextField("keyframe " + clip.subframes[i].frameIndexHi, miniLabelAlignRight); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); } else { framesScroll = Vector2.zero; } } else { SkinDeformationClipRegions.Disable(); EditorGUILayout.HelpBox("Skin Deformation Clip (multiple)", MessageType.Info, true); if (GUILayout.Button("Import")) { foreach (var target in targets) { SkinDeformationClip clip = (SkinDeformationClip)target; ImportClip(clip); } } EditorGUILayout.Separator(); base.OnInspectorGUI(); } }
void OnDisable() { SkinDeformationClipRegions.Disable(); }