Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,18 @@ public void OnAnimEditorGUI(EditorWindow parent, Rect position) {
Rect? audioWaveformRect = null;
if (state.audioControlsState.m_isAudioEnabled && !state.animatorIsOptimized && !m_State.disabled)
{
audioWaveformRect = GUILayoutUtility.GetRect(contentWidth, 80);
if (state.audioControlsState.m_waveformBG && !m_State.showCurveEditor) {
// When the waveform is in the background we essentially don't need a window
audioWaveformRect = GUILayoutUtility.GetRect(contentWidth, 0);
} else {
audioWaveformRect = GUILayoutUtility.GetRect(contentWidth, state.audioControlsState.m_waveformHeight);
}
}

// Calling Waveform before main content in order to draw in bg if needed
AudioWaveformOnGUI(contentLayoutRect, audioWaveformRect);
// MainContent must be done first since it resizes the Zoomable area.
MainContentOnGUI(contentLayoutRect);
TimeRulerOnGUI(timerulerRect);
AudioWaveformOnGUI(audioWaveformRect);
EventLineOnGUI(eventsRect);
GUILayout.EndVertical();

Expand Down Expand Up @@ -634,20 +639,25 @@ private void TimeRulerOnGUI(Rect timeRulerRect) {
RenderOutOfRangeOverlay(timeRulerRectNoScrollbar);
}

private void AudioWaveformOnGUI(Rect? audioWaveformRect)
private void AudioWaveformOnGUI(Rect contentLayoutRect, Rect? audioWaveformRect)
{
if (!audioWaveformRect.HasValue)
{
return;
}
Rect guiRect = audioWaveformRect.Value;

GUI.Box(guiRect, GUIContent.none);
Rect noSlidersRect = new Rect(guiRect.xMin, guiRect.yMin, guiRect.width - kSliderThickness, guiRect.height);

m_State.timeArea.TimeRuler(noSlidersRect, m_State.frameRate, false, true, kDisabledRulerAlpha, m_State.timeFormat); // grid
m_AudioWaveformVisualizer.DrawWaveform(noSlidersRect);

Rect noSlidersRect;
if (state.audioControlsState.m_waveformBG && !m_State.showCurveEditor) {
noSlidersRect = new Rect(contentLayoutRect.xMin, contentLayoutRect.yMax-state.audioControlsState.m_waveformHeight, contentLayoutRect.width - kSliderThickness, state.audioControlsState.m_waveformHeight);
m_AudioWaveformVisualizer.DrawWaveform(noSlidersRect);
} else {
Rect guiRect = audioWaveformRect.Value;
GUI.Box(guiRect, GUIContent.none);

noSlidersRect = new Rect(guiRect.xMin, guiRect.yMin, guiRect.width - kSliderThickness, guiRect.height);
m_State.timeArea.TimeRuler(noSlidersRect, m_State.frameRate, false, true, kDisabledRulerAlpha, m_State.timeFormat); // grid
m_AudioWaveformVisualizer.DrawWaveform(noSlidersRect);
}
if (state.audioControlsState.m_bpmGuideEnabled)
{
m_AudioWaveformVisualizer.DrawBPMGuide(noSlidersRect);
Expand Down Expand Up @@ -1299,4 +1309,4 @@ private void InitializeAudioTools()
m_AnimationWindowSettingsGUI = new AnimationWindowSettingsGUI();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class AnimationWindowSettingsGUI
new GUIContent("BPM", "The beats per minute of the audio.");
private static GUIContent s_WaveformColorField =
new GUIContent("Waveform Color", "The color of the waveform for the audio visualization.");

private static GUIContent s_WaveformHeightField =
new GUIContent("Waveform Height", "The height of the waveform for the audio visualization.");
private static GUIContent s_WaveformBGField =
new GUIContent("Waveform In Background", "Whether the audio visualization is drawn in the background of timeline.");
private static GUIContent s_BpmGuideField =
new GUIContent("BPM Guide Enabled", "Whether to enable BPM guides.");
private static GUIContent s_BeatPrecisionField =
Expand Down Expand Up @@ -164,6 +167,14 @@ private void AudioControlsOnGUI(AudioControlsState audioControls)
audioControls.m_waveformColor = EditorGUILayout.ColorField(s_WaveformColorField, audioControls.m_waveformColor);
EndHorizontal();

BeginHorizontal();
audioControls.m_waveformHeight = EditorGUILayout.IntField(s_WaveformHeightField, audioControls.m_waveformHeight);
EndHorizontal();

BeginHorizontal();
audioControls.m_waveformBG = EditorGUILayout.Toggle(s_WaveformBGField, audioControls.m_waveformBG);
EndHorizontal();

BeginHorizontal();
audioControls.m_latencyMilliseconds = EditorGUILayout.IntField(s_LatencyCompensationField, audioControls.m_latencyMilliseconds);
EndHorizontal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class AudioControlsState : PlayerPrefsSerializer
{
[SerializeField] public bool m_isAudioEnabled = false;
[SerializeField] public Color m_waveformColor = new Color(0, 0.4f, 0.5f, 1);
[SerializeField] public int m_waveformHeight = 80;
[SerializeField] public bool m_waveformBG = false;
[SerializeField] public bool m_bpmGuideEnabled = false;
[SerializeField] public float m_bpm = 60f;
[SerializeField] public Color m_bpmGuideColor = new Color(1, 1, 1, 0.4f);
Expand Down Expand Up @@ -41,6 +43,8 @@ public override void Load()
m_audioClip = AssetDatabase.LoadAssetAtPath<AudioClip>(path);
}
m_waveformColor = LoadColor("waveformColor", new Color(0, 0.4f, 0.5f, 1));
m_waveformHeight = LoadInt("waveformHeight", 80);
m_waveformBG = LoadBool("waveformBG");
m_bpmGuideEnabled = LoadBool("bpmGuideEnabled");
m_bpm = Mathf.Max(1, LoadFloat("bpm", 60));
m_bpmGuideColor = LoadColor("bpmGuideColor", new Color(1, 1, 1, 0.6f));
Expand All @@ -58,6 +62,8 @@ public override void Save()
SaveString("audioClipPath", path);
}
SaveColor("waveformColor", m_waveformColor);
SaveFloat("waveformHeight", m_waveformHeight);
SaveBool("waveformBG", m_waveformBG);
SaveBool("bpmGuideEnabled", m_bpmGuideEnabled);
SaveFloat("bpm", m_bpm);
SaveColor("bpmGuideColor", m_bpmGuideColor);
Expand Down