///The gear context menu for all parameters public static void DoParamGearContextMenu(AnimatedParameter animParam, IKeyable keyable) { var keyableTime = keyable.RootTimeToLocalTime(); var hasKeyNow = animParam.HasKey(keyableTime); var hasAnyKey = animParam.HasAnyKey(); var menu = new GenericMenu(); if (animParam.enabled) { if (hasKeyNow) { menu.AddDisabledItem(new GUIContent("Add Key")); menu.AddItem(new GUIContent("Remove Key"), false, () => { animParam.RemoveKey(keyableTime); }); } else { menu.AddItem(new GUIContent("Add Key"), false, () => { animParam.SetKeyCurrent(keyableTime); }); menu.AddDisabledItem(new GUIContent("Remove Key")); } if (hasAnyKey) { menu.AddItem(new GUIContent("Pre Wrap Mode/Clamp"), false, () => { animParam.SetPreWrapMode(WrapMode.ClampForever); }); menu.AddItem(new GUIContent("Pre Wrap Mode/Loop"), false, () => { animParam.SetPreWrapMode(WrapMode.Loop); }); menu.AddItem(new GUIContent("Pre Wrap Mode/PingPong"), false, () => { animParam.SetPreWrapMode(WrapMode.PingPong); }); menu.AddItem(new GUIContent("Post Wrap Mode/Clamp"), false, () => { animParam.SetPostWrapMode(WrapMode.ClampForever); }); menu.AddItem(new GUIContent("Post Wrap Mode/Loop"), false, () => { animParam.SetPostWrapMode(WrapMode.Loop); }); menu.AddItem(new GUIContent("Post Wrap Mode/PingPong"), false, () => { animParam.SetPostWrapMode(WrapMode.PingPong); }); } else { menu.AddDisabledItem(new GUIContent("Pre Wrap Mode")); menu.AddDisabledItem(new GUIContent("Post Wrap Mode")); } #if SLATE_USE_EXPRESSIONS if (!animParam.hasActiveExpression) { menu.AddItem(new GUIContent("Set Expression"), false, () => { animParam.scriptExpression = "value"; }); menu.AddDisabledItem(new GUIContent("Remove Expression")); } else { menu.AddDisabledItem(new GUIContent("Set Expression")); menu.AddItem(new GUIContent("Remove Expression"), false, () => { animParam.scriptExpression = null; }); } #endif } menu.AddItem(new GUIContent(animParam.enabled ? "Disable" : "Enable"), false, () => { animParam.SetEnabled(!animParam.enabled, keyableTime); }); menu.AddSeparator("/"); if (hasAnyKey) { menu.AddItem(new GUIContent("Remove Animation"), false, () => { if (EditorUtility.DisplayDialog("Reset Animation", "All animation keys will be removed for this parameter.\nAre you sure?", "Yes", "No")) { if (animParam.isExternal) { animParam.RestoreSnapshot(); } animParam.Reset(); if (animParam.isExternal) { animParam.SetSnapshot(); } } }); } else { menu.AddDisabledItem(new GUIContent("Remove Animation")); } if (animParam.isExternal) { menu.AddItem(new GUIContent("Remove Parameter"), false, () => { if (EditorUtility.DisplayDialog("Remove Parameter", "Completely Remove Parameter.\nAre you sure?", "Yes", "No")) { animParam.RestoreSnapshot(); keyable.animationData.RemoveParameter(animParam); CutsceneUtility.RefreshAllAnimationEditorsOf(keyable.animationData); } }); } menu.ShowAsContext(); Event.current.Use(); }