private void DrawBlinkingSwitch(AnimationClip element) { var isRegisteredAsBlinking = _editorEffector.BlinkingContains(element); if (isRegisteredAsBlinking) { CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.RightSideBg); } GUILayout.BeginArea(new Rect((CgeLayoutCommon.GuiSquareWidth - CgeLayoutCommon.PictureWidth) / 2, 0, CgeLayoutCommon.PictureWidth, CgeLayoutCommon.PictureHeight)); _common.DrawPreviewOrRefreshButton(element); GUILayout.EndArea(); GUILayout.Space(CgeLayoutCommon.PictureHeight); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(element, typeof(AnimationClip), true); EditorGUI.EndDisabledGroup(); if (GUILayout.Button(isRegisteredAsBlinking ? CgeLocale.CGEE_EyesAreClosed : "")) { if (isRegisteredAsBlinking) { _editorEffector.RemoveFromBlinking(element); } else { _editorEffector.AddToBlinking(element); } } }
private void LayoutPermutationMatrixProjection(bool partial = false) { for (var sideA = 0; sideA < 8; sideA++) { for (var sideB = 0; sideB < 8; sideB++) { GUILayout.BeginArea(RectAt(sideB, sideA)); DrawInner("anim" + sideA + "" + sideB, "anim" + sideB + "" + sideA, partial); GUILayout.EndArea(); } } for (var side = 1; side < 8; side++) { GUILayout.BeginArea(RectAt(8, side)); DrawInner("anim0" + side, "anim" + side + "0", partial); GUILayout.EndArea(); GUILayout.BeginArea(RectAt(side, 8)); DrawInner("anim" + side + "0", "anim0" + side, partial); GUILayout.EndArea(); } GUILayout.BeginArea(RectAt(0, 8)); CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.LeftSideBg); DrawInner("anim11_L"); GUILayout.EndArea(); GUILayout.BeginArea(RectAt(8, 0)); CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.RightSideBg); DrawInner("anim11_R"); GUILayout.EndArea(); GUILayout.BeginArea(RectAt(8, 8)); DrawTransitionEdit(); if (!GUILayout.Toggle(true, CgeLocale.CGEE_EnablePermutations, GUILayout.ExpandWidth(true), GUILayout.Height(CgeLayoutCommon.SingleLineHeight * 2))) { _editorEffector.SpEnablePermutations().boolValue = false; _editorEffector.SpEditorTool().intValue = 4; } GUILayout.EndArea(); }
private void DrawInner(string propertyPath, string oppositePath = null, bool partial = false) { var usePermutations = oppositePath != null; var property = _editorEffector.SpProperty(propertyPath); var oppositeProperty = usePermutations ? _editorEffector.SpProperty(oppositePath) : null; var isLeftHand = String.Compare(propertyPath, oppositePath, StringComparison.Ordinal) > 0; if (usePermutations) { if (propertyPath == oppositePath) { CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.NeutralSideBg); } else if (property.objectReferenceValue == null && oppositeProperty.objectReferenceValue == null || isLeftHand && property.objectReferenceValue == null && oppositeProperty.objectReferenceValue != null || !isLeftHand && property.objectReferenceValue != null && oppositeProperty.objectReferenceValue == null) { if (isLeftHand && partial) { return; } CgeLayoutCommon.DrawColoredBackground(isLeftHand ? CgeLayoutCommon.LeftSymmetricalBg : CgeLayoutCommon.RightSymmetricalBg); } else if (oppositeProperty.objectReferenceValue == property.objectReferenceValue || isLeftHand && oppositeProperty.objectReferenceValue == null || !isLeftHand && property.objectReferenceValue == null) { CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.InconsistentBg); } else { CgeLayoutCommon.DrawColoredBackground(isLeftHand ? CgeLayoutCommon.LeftSideBg : CgeLayoutCommon.RightSideBg); } } var translatableProperty = usePermutations ? (partial && !isLeftHand && oppositeProperty.objectReferenceValue == null ? propertyPath : ("p_" + propertyPath)) : propertyPath; var isSymmetrical = _driver.IsSymmetrical(translatableProperty); if (!usePermutations) { CgeLayoutCommon.DrawColoredBackground(CgeLayoutCommon.NeutralSideBg); } GUILayout.Label(_driver.ShortTranslation(translatableProperty), isSymmetrical ? _common.MiddleAlignedBold : _common.MiddleAligned); var element = property.objectReferenceValue != null ? (Motion)property.objectReferenceValue : null; if (element != null) { GUILayout.BeginArea(new Rect((CgeLayoutCommon.GuiSquareWidth - CgeLayoutCommon.PictureWidth) / 2, CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.PictureWidth, CgeLayoutCommon.PictureHeight)); _common.DrawPreviewOrRefreshButton(element); GUILayout.EndArea(); } else if (usePermutations) { if (oppositeProperty.objectReferenceValue != null && propertyPath != oppositePath && isLeftHand) { DrawInnerReversal(oppositePath); } } else { // ReSharper disable once PossibleLossOfFraction GUILayout.BeginArea(new Rect((CgeLayoutCommon.GuiSquareWidth - CgeLayoutCommon.PictureWidth) / 2, CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.PictureWidth, CgeLayoutCommon.PictureHeight)); GUILayout.EndArea(); } if (_driver.IsAPropertyThatCanBeCombined(propertyPath, usePermutations) && !(element is BlendTree)) { var rect = element is AnimationClip ? new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 2 * CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 0.5f, CgeLayoutCommon.SingleLineHeight * 2, CgeLayoutCommon.SingleLineHeight * 1.5f) : new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 100, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 0.5f, 100, CgeLayoutCommon.SingleLineHeight * 1.5f); var areSourcesCompatible = _driver.AreCombinationSourcesDefinedAndCompatible(propertyPath, usePermutations); EditorGUI.BeginDisabledGroup(!areSourcesCompatible); GUILayout.BeginArea(rect); if (ColoredBackground(usePermutations, isLeftHand ? CgeLayoutCommon.LeftSideBg : CgeLayoutCommon.RightSideBg, () => GUILayout.Button((element != null ? "+" : "+ " + CgeLocale.CGEE_Combine)))) { var merge = _driver.ProvideCombinationPropertySources(propertyPath, usePermutations); OpenMergeWindowFor(merge.Left, merge.Right, propertyPath, usePermutations); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else if (element is BlendTree) { var rect = new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 20, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 0.5f, 20, CgeLayoutCommon.SingleLineHeight * 1.5f); EditorGUI.BeginDisabledGroup(false); GUILayout.BeginArea(rect); if (GUILayout.Button("?")) { OpenBlendTreeAt(propertyPath); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else { BeginInvisibleRankPreservingArea(); CgeLayoutCommon.InvisibleRankPreservingButton(); EndInvisibleRankPreservingArea(); } if (_driver.IsAPropertyThatCanBeCombinedDiagonally(propertyPath, usePermutations) && !(element is BlendTree)) { var rect = !_driver.IsSymmetrical(propertyPath) || element != null ? new Rect(0, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 0.5f, CgeLayoutCommon.SingleLineHeight * 2, CgeLayoutCommon.SingleLineHeight * 1.5f) : new Rect(0, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 0.5f, 120, CgeLayoutCommon.SingleLineHeight * 1.5f); var areSourcesCompatible = _driver.AreDiagonalCombinationSourcesDefinedAndCompatible(propertyPath, usePermutations); EditorGUI.BeginDisabledGroup(!areSourcesCompatible); GUILayout.BeginArea(rect); if (ColoredBackground(!isSymmetrical, !isLeftHand ? CgeLayoutCommon.LeftSideBg : CgeLayoutCommon.RightSideBg, () => GUILayout.Button(!_driver.IsSymmetrical(propertyPath) || element != null ? "⅃" : "⅃ " + CgeLocale.CGEE_CombineAcross))) { var merge = _driver.ProvideDiagonalCombinationPropertySources(propertyPath, usePermutations); OpenMergeWindowFor(merge.Left, merge.Right, propertyPath, usePermutations); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } if (element == null && !_driver.IsAPropertyThatCanBeCombined(propertyPath, usePermutations)) { EditorGUI.BeginDisabledGroup(false); GUILayout.BeginArea(new Rect(-3 + 10, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 3f, CgeLayoutCommon.GuiSquareWidth - 20, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button("❈ " + CgeLocale.CGEE_Create)) { CreateNewAnimation(propertyPath); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } if (usePermutations && propertyPath != oppositePath && property.objectReferenceValue == oppositeProperty.objectReferenceValue && property.objectReferenceValue != null) { EditorGUI.BeginDisabledGroup(false); GUILayout.BeginArea(new Rect(-3 + 10, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 1.75f, CgeLayoutCommon.GuiSquareWidth - 10, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button("↗↗ " + CgeLocale.CGEE_Simplify)) { Simplify(isLeftHand ? propertyPath : oppositePath); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else if (usePermutations && (isLeftHand && property.objectReferenceValue != null && oppositeProperty.objectReferenceValue == null || !isLeftHand && property.objectReferenceValue == null && oppositeProperty.objectReferenceValue != null)) { EditorGUI.BeginDisabledGroup(false); GUILayout.BeginArea(new Rect(-3 + 10, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 1.75f, CgeLayoutCommon.GuiSquareWidth - 10, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button("↗↙ " + CgeLocale.CGEE_SwapToFix)) { Swap(propertyPath, oppositePath); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else if (usePermutations && isLeftHand && property.objectReferenceValue != null) { EditorGUI.BeginDisabledGroup(false); GUILayout.BeginArea(new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 2 * CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 1.75f, 2 * CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button("↗↙")) { Swap(propertyPath, oppositePath); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else if (element == null && _driver.IsAutoSettable(propertyPath)) { var propertyPathToCopyFrom = _driver.GetAutoSettableSource(propertyPath); var animationToBeCopied = _editorEffector.SpProperty(propertyPathToCopyFrom).objectReferenceValue; EditorGUI.BeginDisabledGroup(animationToBeCopied == null); GUILayout.BeginArea(new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 100, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 1.75f, 100, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button(CgeLocale.CGEE_AutoSet)) { AutoSet(propertyPath, propertyPathToCopyFrom); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else if (element == null && _driver.AreCombinationSourcesIdentical(propertyPath)) { var propertyPathToCopyFrom = _driver.ProvideCombinationPropertySources(propertyPath, usePermutations).Left; var animationToBeCopied = _editorEffector.SpProperty(propertyPathToCopyFrom).objectReferenceValue; EditorGUI.BeginDisabledGroup(animationToBeCopied == null); GUILayout.BeginArea(new Rect(-3 + CgeLayoutCommon.GuiSquareWidth - 100, CgeLayoutCommon.PictureHeight - CgeLayoutCommon.SingleLineHeight * 1.75f, 100, CgeLayoutCommon.SingleLineHeight * 1.5f)); if (GUILayout.Button(CgeLocale.CGEE_AutoSet)) { AutoSet(propertyPath, propertyPathToCopyFrom); } GUILayout.EndArea(); EditorGUI.EndDisabledGroup(); } else { BeginInvisibleRankPreservingArea(); CgeLayoutCommon.InvisibleRankPreservingButton(); EndInvisibleRankPreservingArea(); } GUILayout.Space(CgeLayoutCommon.PictureHeight); EditorGUILayout.PropertyField(property, GUIContent.none); }