/************************************************************************************************************************/ private void DoPlayableNotInitialisedGUI() { if (!EditorApplication.isPlaying) { return; } var target = _Targets[0]; if (EditorUtility.IsPersistent(target.gameObject)) { return; } EditorGUILayout.HelpBox("Playable is not initialised." + " It will be initialised automatically when something needs it, such as playing an animation.", MessageType.Info); var area = GUILayoutUtility.GetLastRect(); AnimancerLayerDrawer.HandleDragAndDropAnimations(area, target, 0); if (!AnimancerEditorUtilities.TryUseContextClick(area)) { return; } var menu = new GenericMenu(); menu.AddItem(new GUIContent("Initialise"), false, () => target.Playable.GetLayer(0)); AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/animation-layers"); menu.ShowAsContext(); }
/************************************************************************************************************************/ #region Context Menu /************************************************************************************************************************/ /// <summary> /// If the <see cref="Event.current"/> is a <see cref="EventType.ContextClick"/> inside the 'clickArea', this /// method opens a context menu which is filled by <see cref="BuildContextMenu"/>. /// </summary> private void CheckContextMenu(Rect clickArea, SerializedProperty rootProperty) { if (!AnimancerEditorUtilities.TryUseContextClick(clickArea)) { return; } var menu = new GenericMenu(); BuildContextMenu(menu, rootProperty); menu.ShowAsContext(); }
/// <summary> /// Checks if the current event is a context menu click within the 'clickArea' and opens a context menu with various /// functions for the <see cref="State"/>. /// </summary> protected void CheckContextMenu(Rect clickArea) { if (!AnimancerEditorUtilities.TryUseContextClick(clickArea)) { return; } var menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(DetailsPrefix + "State: " + State.ToString())); var key = State.Key; if (key != null) { menu.AddDisabledItem(new GUIContent(DetailsPrefix + "Key: " + key)); } AnimancerEditorUtilities.AddMenuItem(menu, "Play", !State.IsPlaying || State.Weight != 1, () => State.Root.Play(State)); AnimancerEditorUtilities.AddFadeFunction(menu, "Cross Fade (Ctrl + Click)", State.Weight != 1, State, (duration) => State.Root.CrossFade(State, duration)); AddContextMenuFunctions(menu); menu.AddItem(new GUIContent(DetailsPrefix + "Log Details"), false, () => Debug.Log("AnimancerState: " + State.GetDescription(true))); menu.AddSeparator(""); menu.AddItem(new GUIContent("Destroy State"), false, () => State.Dispose()); menu.AddSeparator(""); AnimancerEditorUtilities.AddDocumentationLink(menu, "State Documentation", "/docs/manual/animancer-states"); menu.ShowAsContext(); }
/************************************************************************************************************************/ #region Context Menu /************************************************************************************************************************/ /// <summary> /// Checks if the current event is a context menu click within the 'clickArea' and opens a context menu with various /// functions for the <see cref="Layer"/>. /// </summary> private void CheckContextMenu(Rect clickArea) { if (!AnimancerEditorUtilities.TryUseContextClick(clickArea)) { return; } var menu = new GenericMenu(); menu.AddDisabledItem(new GUIContent(Layer.ToString())); AnimancerEditorUtilities.AddMenuItem(menu, "Stop", HasAnyStates((state) => state.IsPlaying || state.Weight != 0), () => Layer.Stop()); AnimancerEditorUtilities.AddFadeFunction(menu, "Fade In", Layer.PortIndex > 0 && Layer.Weight != 1, Layer, (duration) => Layer.StartFade(1, duration)); AnimancerEditorUtilities.AddFadeFunction(menu, "Fade Out", Layer.PortIndex > 0 && Layer.Weight != 0, Layer, (duration) => Layer.StartFade(0, duration)); menu.AddItem(new GUIContent("Inverse Kinematics/Apply Animator IK"), Layer.ApplyAnimatorIK, () => Layer.ApplyAnimatorIK = !Layer.ApplyAnimatorIK); menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Animator IK"), Layer.DefaultApplyAnimatorIK, () => Layer.DefaultApplyAnimatorIK = !Layer.DefaultApplyAnimatorIK); menu.AddItem(new GUIContent("Inverse Kinematics/Apply Foot IK"), Layer.ApplyFootIK, () => Layer.ApplyFootIK = !Layer.ApplyFootIK); menu.AddItem(new GUIContent("Inverse Kinematics/Default Apply Foot IK"), Layer.DefaultApplyFootIK, () => Layer.DefaultApplyFootIK = !Layer.DefaultApplyFootIK); menu.AddSeparator(""); AnimancerEditorUtilities.AddMenuItem(menu, "Destroy States", ActiveStates.Count > 0 || InactiveStates.Count > 0, () => Layer.DestroyStates()); AnimancerEditorUtilities.AddMenuItem(menu, "Add Layer", Layer.Root.LayerCount < AnimancerPlayable.maxLayerCount, () => Layer.Root.LayerCount++); AnimancerEditorUtilities.AddMenuItem(menu, "Remove Layer", Layer.Root.LayerCount > 0, () => Layer.Root.LayerCount--); menu.AddSeparator(""); menu.AddItem(new GUIContent("Keep Weightless Playables Connected"), Layer.Root.KeepPlayablesConnected, () => Layer.Root.KeepPlayablesConnected = !Layer.Root.KeepPlayablesConnected); AddPrefFunctions(menu); menu.AddSeparator(""); AnimancerEditorUtilities.AddDocumentationLink(menu, "Layer Documentation", "/docs/manual/animation-layers"); AddPlayableGraphVisualizerFunction(menu); menu.ShowAsContext(); }