//拖动 private void ProcessDraggingTransformClip(JClipRenderData clip, Vector2 mouseDelta) { if (SourcePositions.ContainsKey(clip)) { ScriptableObject selected = clip.ClipData; if (selected is JSplineKeyframe) { JSplineKeyframe Keyframe = selected as JSplineKeyframe; float mousePosOnTimeline = ContentXToTime(mouseDelta.x + FloatingWidth); float newTime = SourcePositions[clip] + mousePosOnTimeline; newTime = Mathf.Clamp(newTime, 0.0f, CurrentSequence.Duration); int index = Keyframe.Track.Keyframes.IndexOf(Keyframe); if (index == 0) { Keyframe.StartTime = newTime; Keyframe.Track.StartTime = newTime; } else if (index == Keyframe.Track.Keyframes.Count - 1) { Keyframe.StartTime = newTime; Keyframe.Track.EndTime = newTime; } else { newTime = Mathf.Clamp(newTime, Keyframe.Track.Keyframes[index - 1].StartTime, Keyframe.Track.Keyframes[index + 1].StartTime); Keyframe.StartTime = newTime; } if (SelectedObjects.Count == 1) { Selection.activeObject = Keyframe; } } } }
private void ProcessDraggingParticleClip(JClipRenderData clip, Vector2 mouseDelta) { if (SourcePositions.ContainsKey(clip)) { UnityEngine.Object selected = clip.ClipData; if (selected is JParticleClipData) { JParticleClipData particleClipData = selected as JParticleClipData; float mousePosOnTimeline = ContentXToTime(mouseDelta.x + FloatingWidth); float newTime = SourcePositions[clip] + mousePosOnTimeline; newTime = Mathf.Clamp(newTime, 0.0f, CurrentSequence.Duration - particleClipData.PlaybackDuration); particleClipData.StartTime = newTime; if (SelectedObjects.Count == 1) { Selection.activeObject = particleClipData; } } } }
//拖动 private void ProcessDraggingEventClip(JClipRenderData clip, Vector2 mouseDelta) { if (SourcePositions.ContainsKey(clip)) { ScriptableObject selected = clip.ClipData; if (selected is JEventBase) { JEventBase aevent = selected as JEventBase; float mousePosOnTimeline = ContentXToTime(mouseDelta.x + FloatingWidth); float newTime = SourcePositions[clip] + mousePosOnTimeline; newTime = Mathf.Clamp(newTime, 0.0f, CurrentSequence.Duration); aevent.StartTime = newTime; if (SelectedObjects.Count == 1) { Selection.activeObject = aevent; } } } }
private void ProcessDraggingAnimationClip(JClipRenderData clip, Vector2 mouseDelta) { if (SourcePositions.ContainsKey(clip)) { ScriptableObject selected = (ScriptableObject)clip.ClipData; if (selected is JAnimationClipData) { JAnimationClipData animationClipData = selected as JAnimationClipData; //float newTime = ((newPosition.x / DisplayArea.width) * AnimationTimeline.Sequence.Duration) / XScale; // newTime = Mathf.Clamp(newTime, 0.0f, AnimationTimeline.Sequence.Duration); float mousePosOnTimeline = ContentXToTime(FloatingWidth + mouseDelta.x); float newTime = SourcePositions[clip] + mousePosOnTimeline; newTime = Mathf.Clamp(newTime, 0.0f, CurrentSequence.Duration - animationClipData.PlaybackDuration); animationClipData.StartTime = newTime; if (SelectedObjects.Count == 1) { Selection.activeObject = animationClipData; } } } }