public void RetargetActivity(ComboGestureActivity activity) { _editorEffector.NowEditingActivity(activity); if (!_editorEffector.IsPreviewSetupValid()) { _editorEffector.SwitchTo(ActivityEditorMode.OtherOptions); _editorEffector.MarkFirstTimeSetup(); } _window.titleContent = new GUIContent("CGE/" + activity.name); }
private void CreatePreviews() { if (!_editorEffector.IsPreviewSetupValid()) { return; } var animationsPreviews = new[] { _leftPreview, _rightPreview, _combinedPreview }.ToList(); _previewController.GenerateSpecific(animationsPreviews, _editorEffector.PreviewSetup()); }
public void Prepare(AnimationClip baseFace) { if (!_editorEffector.IsPreviewSetupValid()) { return; } for (var visemeNumber = 0; visemeNumber < _visemePreviews.Count; visemeNumber++) { _visemePreviews[visemeNumber] = new EeRenderingSample(GenerateLipsyncClip(baseFace, visemeNumber), _visemePreviews[visemeNumber].RenderTexture, OnClipRendered); } _renderingCommands.GenerateSpecific(_visemePreviews.ToList(), _editorEffector.PreviewSetup()); }
private void OnGUI() { if (_editorEffector.GetCurrentlyEditing() == CurrentlyEditing.Nothing) { return; } if (_editorEffector.IsFirstTimeSetup() && _editorEffector.IsPreviewSetupValid()) { _editorEffector.ClearFirstTimeSetup(); } GUILayout.BeginArea(new Rect(position.width - 320, CgeLayoutCommon.SingleLineHeight * 2 + 5, 200, CgeLayoutCommon.SingleLineHeight + 2)); if (GUILayout.Button(new GUIContent("❈ ExpressionsEditor"), GUILayout.Width(170), GUILayout.Height(CgeLayoutCommon.SingleLineHeight + 2))) { EeAnimationEditorWindow.Obtain().Show(); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(position.width - 130, CgeLayoutCommon.SingleLineHeight * 2 + 5, 100, CgeLayoutCommon.SingleLineHeight + 2)); if (GUILayout.Button(new GUIContent(" " + CgeLocale.CGEE_Tutorials, _helpIcon16), GUILayout.Width(100), GUILayout.Height(CgeLayoutCommon.SingleLineHeight + 2))) { Application.OpenURL(CgeLocale.DocumentationUrl()); } GUILayout.EndArea(); switch (_editorEffector.GetCurrentlyEditing()) { case CurrentlyEditing.Nothing: break; case CurrentlyEditing.Activity: EditingAnActivity(); break; case CurrentlyEditing.Puppet: EditingAPuppet(); break; default: throw new ArgumentOutOfRangeException(); } }
public void DrawPreviewOrRefreshButton(Motion element, bool grayscale = false) { if (element is AnimationClip clip) { if (_memoryQuery.HasClip(clip)) { GUILayout.Box(Texture(grayscale, clip), GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingButton(); } else { InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); EditorGUI.BeginDisabledGroup(AnimationMode.InAnimationMode()); var isPreviewSetupValid = _editorEffector.IsPreviewSetupValid(); if (GUILayout.Button(isPreviewSetupValid ? CgeLocale.CGEE_GeneratePreview : CgeLocale.CGEE_SetupPreview, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { if (isPreviewSetupValid) { _activityPreviewQueryAggregator.GenerateMissingPreviewsPrioritizing(_repaintCallback, clip); } else { if (_editorEffector.GetCurrentlyEditing() == CurrentlyEditing.Activity) { _editorEffector.SwitchTo(ActivityEditorMode.OtherOptions); } else { _editorEffector.SwitchTo(PuppetEditorMode.OtherOptions); } } } EditorGUI.EndDisabledGroup(); } } else if (element is BlendTree tree) { var animations = ManifestFromPuppet.AllAnimationsOf(tree); if (animations.Count == 0) { InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingButton(); } else if (_memoryQuery.HasClip(animations[0])) { GUILayout.BeginHorizontal(); TexturedBox(grayscale, animations, 0); TexturedBox(grayscale, animations, 1); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); TexturedBox(grayscale, animations, 2); TexturedBox(grayscale, animations, 3); GUILayout.EndHorizontal(); InvisibleRankPreservingButton(); } else { InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); EditorGUI.BeginDisabledGroup(AnimationMode.InAnimationMode()); var isPreviewSetupValid = _editorEffector.IsPreviewSetupValid(); if (GUILayout.Button(isPreviewSetupValid ? CgeLocale.CGEE_GeneratePreview : CgeLocale.CGEE_SetupPreview, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) { if (isPreviewSetupValid) { _activityPreviewQueryAggregator.GenerateMissingPreviewsPrioritizing(_repaintCallback, animations[0]); } else { _editorEffector.SwitchTo(ActivityEditorMode.OtherOptions); } } EditorGUI.EndDisabledGroup(); } } else { InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingBox(); InvisibleRankPreservingButton(); } }
private void LayoutLimitedLipsyncEditor(Action repaintCallback) { Rect RectAt(int xGrid, int yGrid) { return(new Rect(xGrid * CgeLayoutCommon.GuiSquareWidth * 2, yGrid * CgeLayoutCommon.GuiSquareHeight * 2, CgeLayoutCommon.GuiSquareWidth * 2, CgeLayoutCommon.GuiSquareHeight * 2)); } if (_lipsyncState.LimitedLipsync == null) { EditorGUILayout.LabelField("Select a ComboGestureLimitedLipsync component in the scene or choose one:"); var newLipsync = (ComboGestureLimitedLipsync)EditorGUILayout.ObjectField(null, typeof(ComboGestureLimitedLipsync), true); if (newLipsync != null) { SetLipsync(newLipsync, repaintCallback); } return; } void DrawLipsync(int visemeNumber, bool previewable) { GUILayout.Label(_driver.ShortTranslation("viseme" + visemeNumber), _common.MiddleAligned); GUILayout.BeginArea(new Rect(CgeLayoutCommon.GuiSquareWidth - CgeLayoutCommon.PictureWidth, CgeLayoutCommon.SingleLineHeight, CgeLayoutCommon.PictureWidth * 2, CgeLayoutCommon.PictureHeight * 2 + CgeLayoutCommon.SingleLineHeight * 4)); GUILayout.Box(_lipsyncState.Lipsync.TextureForViseme(visemeNumber), GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); EditorGUI.BeginDisabledGroup(!previewable || AnimationMode.InAnimationMode()); if (GUILayout.Button("Regenerate preview")) { RegenerateLipsyncPreview(visemeNumber); } EditorGUI.EndDisabledGroup(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Amp Mul", GUILayout.Width(80)); EditorGUILayout.Slider(_lipsyncState.SerializedLimitedLipsync.FindProperty("amplitude" + visemeNumber), 0f, 1f, GUIContent.none, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Duration Mul", GUILayout.Width(80)); EditorGUILayout.Slider(_lipsyncState.SerializedLimitedLipsync.FindProperty("transition" + visemeNumber), 0f, 1f, GUIContent.none, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.Space(CgeLayoutCommon.PictureHeight); } GUILayout.BeginArea(RectAt(0, 0)); EditorGUILayout.LabelField("Limited Lipsync Component", EditorStyles.boldLabel); var otherNewLipsync = (ComboGestureLimitedLipsync)EditorGUILayout.ObjectField(_lipsyncState.LimitedLipsync, typeof(ComboGestureLimitedLipsync), true); if (!IsLimitedLipsyncSameAs(otherNewLipsync)) { SetLipsync(otherNewLipsync, repaintCallback); } EditorGUILayout.PropertyField(_lipsyncState.SerializedLimitedLipsync.FindProperty("limitation"), new GUIContent("Category")); EditorGUILayout.Slider(_lipsyncState.SerializedLimitedLipsync.FindProperty("amplitudeScale"), 0f, 0.25f, "Viseme Amplitude"); EditorGUILayout.Slider(_lipsyncState.SerializedLimitedLipsync.FindProperty("amplitudeScale"), 0f, 1f, "(scaled to 1)"); EditorGUILayout.PropertyField(_lipsyncState.SerializedLimitedLipsync.FindProperty("transitionDuration"), new GUIContent("Transition Duration (s)")); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Preview", EditorStyles.boldLabel); var previewables = ListAllPreviewableNames(); var previewIsPossible = previewables.Any(); if (previewIsPossible) { if (_lipsyncState.LimitedLipsyncPreviewIndex >= previewables.Length) { _lipsyncState.LimitedLipsyncPreviewIndex = 0; } _lipsyncState.LimitedLipsyncPreviewIndex = EditorGUILayout.Popup( _lipsyncState.LimitedLipsyncPreviewIndex, previewables ); var avatarHasVisemeBlendShapes = _editorEffector.IsPreviewSetupValid() && _editorEffector.PreviewSetup().TempCxSmr; if (!avatarHasVisemeBlendShapes) { EditorGUILayout.HelpBox("The avatar has no lipsync face mesh.", MessageType.Error); } EditorGUI.BeginDisabledGroup(AnimationMode.InAnimationMode()); if (GUILayout.Button("Regenerate all previews")) { RegenerateLipsyncPreviews(); } EditorGUI.EndDisabledGroup(); } else { if (GUILayout.Button("Select an animation...")) { // _editorEffector.SwitchTo(ActivityEditorMode.MakeLipsyncMovementsSubtle); _lipsyncState.EditorLipsyncTool = 0; } } GUILayout.EndArea(); for (var viseme = 0; viseme < 15; viseme++) { var gridIndex = viseme + 1; GUILayout.BeginArea(RectAt(gridIndex % 4, gridIndex / 4)); DrawLipsync(viseme, previewIsPossible); GUILayout.EndArea(); } }
public void Layout(Action repaintCallback, Rect position) { _common.BeginLayoutUsingWidth(position, CgeLayoutCommon.GuiSquareHeight * 2, 0, CgeLayoutCommon.GuiSquareWidth * 4); if (_editorEffector.IsFirstTimeSetup() || !_editorEffector.IsPreviewSetupValid()) { if (_editorEffector.HasPreviewSetupWhichIsInvalid()) { EditorGUILayout.LabelField(CgeLocale.CGEE_IncompletePreviewSetup); } EditorGUILayout.PropertyField(_editorEffector.SpPreviewSetup(), new GUIContent(CgeLocale.CGEE_Preview_setup)); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CgeLocale.CGEE_Automatically_setup_preview, GUILayout.Height(50), GUILayout.Width(300))) { DoAutoSetupPreview(); if (_editorEffector.GetSetupResult() != EePreviewSetupWizard.SetupResult.NoAvatarFound) { _editorEffector.SwitchTo(ActivityEditorMode.SetFaceExpressions); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { EditorGUILayout.PropertyField(_editorEffector.SpTransitionDuration(), new GUIContent(CgeLocale.CGEE_Transition_duration)); EditorGUILayout.PropertyField(_editorEffector.SpPreviewSetup(), new GUIContent(CgeLocale.CGEE_Preview_setup)); if (_editorEffector.GetSetupResult() != null) { var setupResult = (EePreviewSetupWizard.SetupResult)_editorEffector.GetSetupResult(); switch (setupResult) { case EePreviewSetupWizard.SetupResult.ReusedExistsAndValidInScene: EditorGUILayout.HelpBox(CgeLocale.CGEE_AutoSetupReused, MessageType.Info); break; case EePreviewSetupWizard.SetupResult.NoAvatarFound: EditorGUILayout.HelpBox(CgeLocale.CGEE_AutoSetupNoActiveAvatarDescriptor, MessageType.Error); break; case EePreviewSetupWizard.SetupResult.CreatedNew: EditorGUILayout.HelpBox(CgeLocale.CGEE_AutoSetupCreated, MessageType.Info); break; default: throw new ArgumentOutOfRangeException(); } } EditorGUI.BeginDisabledGroup(AnimationMode.InAnimationMode()); if (GUILayout.Button(CgeLocale.CGEE_Generate_missing_previews)) { _activityPreviewQueryAggregator.GenerateMissingPreviews(repaintCallback); } if (GUILayout.Button(CgeLocale.CGEE_Regenerate_all_previews)) { _activityPreviewQueryAggregator.GenerateAll(repaintCallback); } if (_editorEffector.GetCurrentlyEditing() == CurrentlyEditing.Activity) { EditorGUILayout.PropertyField(_editorEffector.SpEditorArbitraryAnimations(), new GUIContent(CgeLocale.CGEE_List_of_arbitrary_animations), true); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!AnimationMode.InAnimationMode()); EditorGUI.EndDisabledGroup(); if (_editorEffector.GetCurrentlyEditing() == CurrentlyEditing.Activity) { if (_editorEffector.GetActivity().editorArbitraryAnimations != null) { GUILayout.BeginArea(new Rect(0, CgeLayoutCommon.SingleLineHeight * 10, position.width, CgeLayoutCommon.GuiSquareHeight * 8)); var allClips = new HashSet <AnimationClip>(_editorEffector.GetActivity().editorArbitraryAnimations.Where(clip => clip != null)).ToList(); var mod = (int)Math.Max(1, position.width / CgeLayoutCommon.GuiSquareWidth); for (var element = 0; element < allClips.Count; element++) { GUILayout.BeginArea(CgeLayoutCommon.RectAt(element % mod, element / mod)); DrawArbitrary(allClips[element]); GUILayout.EndArea(); } GUILayout.EndArea(); GUILayout.Space((allClips.Count / mod) * CgeLayoutCommon.GuiSquareHeight + CgeLayoutCommon.GuiSquareHeight + CgeLayoutCommon.SingleLineHeight * 2); } } } CgeLayoutCommon.EndLayout(); }