public bool RemoveKeyframeEvent(AnimationEventController.AdvancedAnimationEvent selected, int frame) { AnimationClip clip = FindClipInAnimator(selected.clipName); int frameCount = GetClipFrameCount(selected.clipName); if (frame == 0 || frame == frameCount - 1) { return(false); } //TODO : RecordObject("[AECE] Remove keyframeEvent"); for (int i = 0; i < selected.keyframeEvents.Count; i++) { if (selected.keyframeEvents[i].eventKeyframe == frame) { selected.keyframeEvents.Remove(selected.keyframeEvents[i]); RemoveEventInClip(clip, frame); return(true); } } return(false); }
//TODO : 스트링 서치로 변경 public bool AddEventAnimation(string clipName) { if (animationEventController.Contains(clipName)) { return(false); } // RecordObject("[AECE] Add Selected Animatin"); AnimationClip clip = FindClipInAnimator(clipName); if (!clip) { return(false); } AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent = animationEventController.Add(clip.name); float frameCount = GetClipFrameCount(clipName); if (frameCount > 0.0f) { AddKeyframeEvent(advancedAnimationEvent, 0); AddKeyframeEvent(advancedAnimationEvent, (int)frameCount - 1); } return(true); }
private void DrawKeyframeEventIcon(int frame, Vector2 position) { AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent = AnimationEventControllerEditorWindow.Instance.current.eventAnimation; if (advancedAnimationEvent == null) { return; } if (AnimationEventControllerEditorWindow.Instance.IsEventFrameInAdvancedAnimationEvents(advancedAnimationEvent, frame)) { if (currentFrameIndex == frame) { if (frame == 0 || frame == AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"ProfilerTimelineRollUpArrow"); } else { GUI.Button(new Rect(position.x, position.y, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"TL Playhead"); } } else { if (frame == 0 || frame == AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"ProfilerTimelineRollUpArrow"); } else { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"U2D.dragDotDimmed"); } } } }
private void DrawKeyframeEventIcon(int frame, Vector2 position) { AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent = AnimationEventControllerEditorWindow.Instance.current.eventAnimation; if (advancedAnimationEvent == null) { return; } if (AnimationEventControllerEditorWindow.Instance.IsEventFrameInAdvancedAnimationEvents(advancedAnimationEvent, frame)) { if (currentFrameIndex == frame) { if (frame == 0 || frame == AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"TrackCollapseMarkerButton"); } else { GUI.Button(new Rect(position.x, position.y, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"TL Playhead"); } } else { if (frame == 0 || frame == AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"TrackCollapseMarkerButton"); } else { GUI.Button(new Rect(position.x - 7.5f, position.y - 1.8f, 10.0f, 10.0f), new GUIContent(""), (GUIStyle)"Icon.AvatarMaskOff"); } } } }
public void MatchingAnimationClip(AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent, string clipName) { foreach (var iter in matchEvents) { if (iter.clipName == clipName) { RemoveEventAnimation(clipName); } } advancedAnimationEvent.clipName = clipName; advancedAnimationEvent.clip = FindClipInAnimator(clipName); }
public bool IsEventFrameInAdvancedAnimationEvents(AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent, int frame) { AnimationEventController.AdvancedAnimationEvent animationEvent = advancedAnimationEvent; foreach (var iter in animationEvent.keyframeEvents) { if (iter.eventKeyframe == frame) { return(true); } } return(false); }
//재검토a public int FindEventAnimationIndex(AnimationEventController.AdvancedAnimationEvent data) { if (data == null) { return(0); } int count = 0; foreach (var iter in animationEventController.animationEvents) { if (iter.clipName == data.clipName) { break; } count++; } return(count); }
public bool AddKeyframeEvent(AnimationEventController.AdvancedAnimationEvent selected, int frame) { AnimationClip clip = FindClipInAnimator(selected.clipName); if (!clip) { return(false); } if (!IsUnityAnimationEventInClip(clip, frame)) { if (!IsEventFrameInAdvancedAnimationEvents(selected, frame)) { string eventName = selected.clipName + frame; AnimationEventController.UnityKeyframeEvent newKeyframeEvent = new AnimationEventController.UnityKeyframeEvent(eventName, frame, null); selected.keyframeEvents.Add(newKeyframeEvent); AttachUnityAnimationEventToClip(newKeyframeEvent, clip); return(true); } for (int i = 0; i < selected.keyframeEvents.Count; i++) { if (selected.keyframeEvents[i].eventKeyframe == frame) { AttachUnityAnimationEventToClip(selected.keyframeEvents[i], clip); return(true); } } } //TODO : RecordObject("[AECE] Add keyframeEvent"); return(false); }
public override void ProcessEvents(Event e) { base.ProcessEvents(e); switch (e.type) { case EventType.MouseDown: { if (workTimelineView.IsInTimelineView(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y))) { if (e.button == 0) { int index = workTimelineView.GetFrameIndexOfRange(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y)); if (index != -1) { AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex = index; isDragged = true; e.Use(); } } } else if (workTimelineView.IsInKeyframeView(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y))) { if (e.button == 0) { int index = workTimelineView.GetFrameIndexOfRange(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y)); if (index != -1) { AnimationEventController.UnityKeyframeEvent keyframeEvent = AnimationEventControllerEditorWindow.Instance.GetKeyframeEventInCurrentEventAnimation(index); if (keyframeEvent != null) { if (keyframeEvent.eventKeyframe != 0 && keyframeEvent.eventKeyframe != AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { selectedKeyframeEvent = keyframeEvent; } else { selectedKeyframeEvent = null; } } AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex = index; isEventDragged = true; e.Use(); } } else if (e.button == 1) { int index = workTimelineView.GetFrameIndexOfRange(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y)); if (index != -1) { AnimationEventController.AdvancedAnimationEvent advancedAnimationEvent = AnimationEventControllerEditorWindow.Instance.current.eventAnimation; for (int i = 0; i < advancedAnimationEvent.keyframeEvents.Count; i++) { if (advancedAnimationEvent.keyframeEvents[i].eventKeyframe == index) { KeyframeEventRemoveGenericMenu(e, AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex); return; } } KeyframeEventAddGenericMenu(e, AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex); } } } } break; case EventType.MouseUp: { isDragged = false; isEventDragged = false; selectedKeyframeEvent = null; } break; case EventType.MouseDrag: { if (isDragged && workTimelineView.IsInView(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y))) { int index = workTimelineView.GetFrameIndexOfRange(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y)); if (index != -1) { AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex = index; e.Use(); } } else if (isEventDragged && workTimelineView.IsInView(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y))) { int index = workTimelineView.GetFrameIndexOfRange(new Vector2(e.mousePosition.x - viewRect.x, e.mousePosition.y - viewRect.y)); if (index != -1 && AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex != index) { if (index != 0 && index != AnimationEventControllerEditorWindow.Instance.GetCurrentEventAnimationClipFrameCount() - 1) { AnimationEventController.UnityKeyframeEvent keyframeEvent = AnimationEventControllerEditorWindow.Instance.GetKeyframeEventInCurrentEventAnimation(index); if (selectedKeyframeEvent != null) { selectedKeyframeEvent = AnimationEventControllerEditorWindow.Instance.SwapKeyFrameEvent(index, selectedKeyframeEvent); } } AnimationEventControllerEditorWindow.Instance.current.timeline.frameIndex = index; e.Use(); } } } break; } }