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 DrawArbitrary(AnimationClip element) { 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(); }
private void DrawLipsyncSwitch(AnimationClip element) { var isRegisteredAsLipsync = _editorEffector.MutableLimitedLipsync().Exists(animation => animation.clip == element); if (isRegisteredAsLipsync) { var col = GUI.color; try { GUI.color = new Color(0.44f, 0.65f, 1f); GUI.Box(new Rect(0, 0, CgeLayoutCommon.GuiSquareWidth, CgeLayoutCommon.GuiSquareHeight), ""); } finally { GUI.color = col; } } 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(isRegisteredAsLipsync ? "Limited Lipsync" : "")) { if (isRegisteredAsLipsync) { _editorEffector.MutableLimitedLipsync().RemoveAll(animation => animation.clip == element); } else { _editorEffector.MutableLimitedLipsync().Add(new ComboGestureActivity.LimitedLipsyncAnimation { clip = element, limitation = ComboGestureActivity.LipsyncLimitation.WideOpenMouth }); } } }
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); }
private void LayoutBlendTreeViewer(Rect position, bool showAsset) { BlendTree treeBeingEdited; if (_editorEffector.GetCurrentlyEditing() == CurrentlyEditing.Puppet) { var value = _editorEffector.SpProperty("mainTree").objectReferenceValue; if (value != null && value is AnimationClip) { _editorEffector.SpProperty("mainTree").objectReferenceValue = null; treeBeingEdited = null; } else { treeBeingEdited = (BlendTree)value; } } else { treeBeingEdited = _blendTreeEffector.BlendTreeBeingEdited; } if (showAsset) { // EditorGUI.BeginDisabledGroup(true); _blendTreeEffector.BlendTreeBeingEdited = (BlendTree)EditorGUILayout.ObjectField(treeBeingEdited, typeof(BlendTree), false); // EditorGUI.EndDisabledGroup(); } if (treeBeingEdited == null) { return; } var is2D = treeBeingEdited.blendType == BlendTreeType.Simple1D || treeBeingEdited.blendType == BlendTreeType.Direct; var xMin = treeBeingEdited.children.Select(motion => is2D ? motion.threshold : motion.position.x).Min(); var yMin = treeBeingEdited.children.Select(motion => is2D ? 0 : motion.position.y).Min(); var xMax = treeBeingEdited.children.Select(motion => is2D ? motion.threshold : motion.position.x).Max(); var yMax = treeBeingEdited.children.Select(motion => is2D ? 1 : motion.position.y).Max(); var min = new Vector2(xMin, yMin); var max = new Vector2(xMax, yMax); var headerPadding = 5 * CgeLayoutCommon.SingleLineHeight; var fixture = 5 * CgeLayoutCommon.SingleLineHeight; var sliderThickness = CgeLayoutCommon.SingleLineHeight * 2; _blendTreeEffector.DescaleLevel = GUI.HorizontalSlider( new Rect(100, fixture - sliderThickness, position.width - 200, sliderThickness), _blendTreeEffector.DescaleLevel, 0.01f, 1f ); _blendTreeEffector.HorizontalFocalPoint = GUI.HorizontalSlider( new Rect(sliderThickness, fixture, position.width - sliderThickness, sliderThickness), _blendTreeEffector.HorizontalFocalPoint, 0, 1f ); _blendTreeEffector.VerticalFocalPoint = GUI.VerticalSlider( new Rect(0, fixture + sliderThickness, sliderThickness, position.height - fixture - headerPadding - sliderThickness), _blendTreeEffector.VerticalFocalPoint, 0, 1f ); GUILayout.BeginArea(new Rect( sliderThickness, fixture + sliderThickness, position.width - sliderThickness, position.height - fixture - sliderThickness - CgeLayoutCommon.SingleLineHeight * 4)); foreach (var child in treeBeingEdited.children) { var posVec = is2D ? new Vector2(child.threshold, 0.5f) : child.position; var centered = CalculateCentered(posVec, min, max, position, headerPadding, fixture, sliderThickness); GUILayout.BeginArea(centered); GUILayout.BeginArea(new Rect(0, 0, CgeLayoutCommon.PictureWidth, CgeLayoutCommon.PictureHeight)); _common.DrawPreviewOrRefreshButton(child.motion); GUILayout.EndArea(); GUILayout.EndArea(); } GUILayout.EndArea(); }