private void ResetSettings() { _currentMarker = null; _isPlaying = false; _isLooping = false; _currentSample = 0; _fableNeedUpdate = false; }
private void ProcessEvents(Event e) { if (audioClip != null) { switch (e.type) { case EventType.MouseDown: if (e.button == 0) { UpdateWaveformTimeline(e.mousePosition); if (IsCursorOnMarker(e.mousePosition)) { foreach (TimestampMarker marker in _markers) { if (GetChildRect(marker.rect, _audioEditArea, _scrollRect).Contains(e.mousePosition)) { _currentMarker = marker; Repaint(); break; } } } } else if (e.button == 1) { ProcessContextMenu(e.mousePosition); } break; case EventType.MouseDrag: if (e.button == 0) { UpdateWaveformTimeline(e.mousePosition); if (IsCursorOnMarker(e.mousePosition)) { bool shouldRepaint = false; foreach (TimestampMarker marker in _markers) { if (GetChildRect(marker.rect, _audioEditArea, _scrollRect).Contains(e.mousePosition)) { marker.Drag(e.delta.x, audioClip.length, _toolBox.sliderValue); shouldRepaint = true; } } if (shouldRepaint) { Repaint(); } } } break; } } }
private void AddMarker(object mousePosition) { Vector2 pos = (Vector2)mousePosition; float audioTimeFraction = (pos.x - GetChildRect(_audioEditArea, _markerBox).x) / _toolBox.sliderValue; float audioTime = audioTimeFraction * audioClip.length; int sampleTime = Mathf.CeilToInt(audioTimeFraction * (float)audioClip.samples); _markers.Add(new TimestampMarker(audioTime, sampleTime)); _currentMarker = _markers.Last(); Repaint(); }