void OnDisable() { MecanimEventEditorPopup.Destroy(); if (eventInspector != null) { eventInspector.SetPreviewMotion(null); eventInspector.SaveData(); } }
public static MecanimEventEditorPopup Show(MecanimEventEditor editor, MecanimEvent e, KeyValuePair<string, EventConditionParamTypes>[] availableParameters) { actived = EditorWindow.GetWindow<MecanimEventEditorPopup>(false, "Edit Event"); actived.eventEditing = e; actived.eventTemp = new MecanimEvent(e); actived.editor = editor; actived.availableParameters = availableParameters; actived.conditionList = new UnityEditorInternal.ReorderableList(actived.eventTemp.condition.conditions, typeof(EventConditionEntry)); actived.conditionList.drawElementCallback = new UnityEditorInternal.ReorderableList.ElementCallbackDelegate(actived.DrawConditionsElement); actived.conditionList.drawHeaderCallback = new UnityEditorInternal.ReorderableList.HeaderCallbackDelegate(actived.DrawConditionsHeader); return actived; }
public static MecanimEventEditorPopup Show(MecanimEventEditor editor, MecanimEvent e, KeyValuePair <string, EventConditionParamTypes>[] availableParameters) { actived = EditorWindow.GetWindow <MecanimEventEditorPopup>(false, "Edit Event"); actived.eventEditing = e; actived.eventTemp = new MecanimEvent(e); actived.editor = editor; actived.availableParameters = availableParameters; actived.conditionList = new UnityEditorInternal.ReorderableList(actived.eventTemp.condition.conditions, typeof(EventConditionEntry)); actived.conditionList.drawElementCallback = new UnityEditorInternal.ReorderableList.ElementCallbackDelegate(actived.DrawConditionsElement); actived.conditionList.drawHeaderCallback = new UnityEditorInternal.ReorderableList.HeaderCallbackDelegate(actived.DrawConditionsHeader); return(actived); }
void Reset() { displayEvents = null; targetController = null; targetStateMachine = null; targetState = null; targetEvent = null; selectedLayer = 0; selectedState = 0; selectedEvent = 0; MecanimEventEditorPopup.Destroy(); }
void OnGUI() { if (eventInspector == null) { Reset(); ShowNotification(new GUIContent("Select a MecanimEventData object first.")); return; } RemoveNotification(); GUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); DrawControllerPanel(); DrawLayerPanel(); DrawStatePanel(); if (EditorGUI.EndChangeCheck()) { MecanimEventEditorPopup.Destroy(); } DrawEventPanel(); } GUILayout.EndHorizontal(); if (targetState != null && targetState.motion != null) { eventInspector.SetPreviewMotion(targetState.motion); } else { eventInspector.SetPreviewMotion(null); } GUILayout.Space(5); GUILayout.BeginHorizontal(GUILayout.MaxHeight(100)); { DrawTimelinePanel(); } GUILayout.EndHorizontal(); }
private void DrawEventKey(Rect rect, MecanimEvent key) { float keyTime = key.normalizedTime; Rect keyRect = new Rect(rect.x + rect.width * keyTime - 3, rect.y + 25, 6, 18); int eventKeyCtrl = key.GetHashCode(); Event e = Event.current; switch (e.type) { case EventType.Repaint: Color savedColor = GUI.color; if (targetEvent == key) { GUI.color = Color.red; } else { GUI.color = Color.green; } GUI.skin.button.Draw(keyRect, new GUIContent(), eventKeyCtrl); GUI.color = savedColor; if (hotEventKey == eventKeyCtrl || (hotEventKey == 0 && keyRect.Contains(e.mousePosition))) { string labelString = string.Format("{0}({1})@{2}", key.functionName, key.parameter, key.normalizedTime.ToString("0.0000")); Vector2 size = EditorStyles.largeLabel.CalcSize(new GUIContent(labelString)); Rect infoRect = new Rect(rect.x + rect.width * keyTime - size.x / 2, rect.y + 50, size.x, size.y); EditorStyles.largeLabel.Draw(infoRect, new GUIContent(labelString), eventKeyCtrl); } break; case EventType.MouseDown: if (keyRect.Contains(e.mousePosition)) { hotEventKey = eventKeyCtrl; enableTempPreview = true; tempPreviewPlaybackTime = key.normalizedTime; SetActiveEvent(key); if (e.clickCount > 1) { MecanimEventEditorPopup.Show(this, key, GetConditionParameters()); } e.Use(); } break; case EventType.MouseDrag: if (hotEventKey == eventKeyCtrl) { if (e.button == 0) { Vector2 guiPos = e.mousePosition; float clampedX = Mathf.Clamp(guiPos.x, rect.x, rect.x + rect.width); key.normalizedTime = (clampedX - rect.x) / rect.width; tempPreviewPlaybackTime = key.normalizedTime; SetActiveEvent(key); } e.Use(); } break; case EventType.MouseUp: if (hotEventKey == eventKeyCtrl) { hotEventKey = 0; enableTempPreview = false; eventInspector.SetPlaybackTime(playbackTime); // reset to original time if (e.button == 1) { MecanimEventEditorPopup.Show(this, key, GetConditionParameters()); } e.Use(); } break; } }
void DrawTimelinePanel() { if (!enableTempPreview) { playbackTime = eventInspector.GetPlaybackTime(); } GUILayout.BeginVertical(); { GUILayout.Space(10); GUILayout.BeginHorizontal(); { GUILayout.Space(20); playbackTime = Timeline(playbackTime); GUILayout.Space(10); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Tools")) { GenericMenu menu = new GenericMenu(); GenericMenu.MenuFunction2 callback = delegate(object obj) { int id = (int)obj; switch (id) { case 1: { //stateClipboard = eventInspector.GetEvents(targetController, selectedLayer, targetState.uniqueNameHash); break; } case 2: { //eventInspector.InsertEventsCopy(targetController, selectedLayer, targetState.uniqueNameHash, stateClipboard); break; } case 3: { controllerClipboard = eventInspector.GetEvents(targetController); break; } case 4: { eventInspector.InsertControllerEventsCopy(targetController, controllerClipboard); break; } } }; if (targetState == null) { menu.AddDisabledItem(new GUIContent("Copy All Events From Selected State")); } else { menu.AddItem(new GUIContent("Copy All Events From Selected State"), false, callback, 1); } if (targetState == null || stateClipboard == null || stateClipboard.Length == 0) { menu.AddDisabledItem(new GUIContent("Paste All Events To Selected State")); } else { menu.AddItem(new GUIContent("Paste All Events To Selected State"), false, callback, 2); } if (targetController == null) { menu.AddDisabledItem(new GUIContent("Copy All Events From Selected Controller")); } else { menu.AddItem(new GUIContent("Copy All Events From Selected Controller"), false, callback, 3); } if (targetController == null || controllerClipboard == null || controllerClipboard.Count == 0) { menu.AddDisabledItem(new GUIContent("Paste All Events To Selected Controller")); } else { menu.AddItem(new GUIContent("Paste All Events To Selected Controller"), false, callback, 4); } menu.ShowAsContext(); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Add", GUILayout.Width(80))) { MecanimEvent newEvent = new MecanimEvent(); newEvent.normalizedTime = playbackTime; newEvent.functionName = "MessageName"; newEvent.paramType = MecanimEventParamTypes.None; displayEvents.Add(newEvent); SortEvents(); SetActiveEvent(newEvent); MecanimEventEditorPopup.Show(this, newEvent, GetConditionParameters()); } if (GUILayout.Button("Del", GUILayout.Width(80))) { DelEvent(targetEvent); } EditorGUI.BeginDisabledGroup(targetEvent == null); if (GUILayout.Button("Copy", GUILayout.Width(80))) { clipboard = new MecanimEvent(targetEvent); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(clipboard == null); if (GUILayout.Button("Paste", GUILayout.Width(80))) { MecanimEvent newEvent = new MecanimEvent(clipboard); displayEvents.Add(newEvent); SortEvents(); SetActiveEvent(newEvent); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(targetEvent == null); if (GUILayout.Button("Edit", GUILayout.Width(80))) { MecanimEventEditorPopup.Show(this, targetEvent, GetConditionParameters()); } EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Save", GUILayout.Width(80))) { eventInspector.SaveData(); } if (GUILayout.Button("Close", GUILayout.Width(80))) { Close(); } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (enableTempPreview) { eventInspector.SetPlaybackTime(tempPreviewPlaybackTime); eventInspector.StopPlaying(); } else { eventInspector.SetPlaybackTime(playbackTime); } SaveState(); }
private void OnDestroy() { actived = null; }
void OnDestroy() { actived = null; }