Playback speed slider

This commit is contained in:
Braedon
2022-02-03 02:28:14 -05:00
parent 44a36ba846
commit cf24d11cf8
9 changed files with 764 additions and 20 deletions

View File

@ -75,6 +75,7 @@ namespace RhythmHeavenMania.Editor.Track
public Button SelectionsBTN;
public Button TempoChangeBTN;
public Button MusicVolumeBTN;
public Slider PlaybackSpeed;
public static Timeline instance { get; private set; }
@ -182,6 +183,8 @@ namespace RhythmHeavenMania.Editor.Track
Tooltip.AddTooltip(TempoChangeBTN.gameObject, "Tool: Tempo Change <color=#adadad>[2]</color>");
Tooltip.AddTooltip(MusicVolumeBTN.gameObject, "Tool: Music Volume <color=#adadad>[3]</color>");
Tooltip.AddTooltip(PlaybackSpeed.gameObject, "The preview's playback speed. Right click to reset to 1.0");
SetTimeButtonColors(true, false, false);
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
@ -526,6 +529,23 @@ namespace RhythmHeavenMania.Editor.Track
return LayersRect.rect.height / 4;
}
public void SetPlaybackSpeed(float speed)
{
float spd = Mathp.Round2Nearest(speed, 0.25f);
PlaybackSpeed.transform.GetChild(3).GetComponent<TMP_Text>().text = $"Playback Speed: {spd}x";
Conductor.instance.musicSource.pitch = spd;
PlaybackSpeed.value = spd;
}
public void ResetPlaybackSpeed()
{
if (Input.GetMouseButton(1))
{
PlaybackSpeed.transform.GetChild(3).GetComponent<TMP_Text>().text = $"Playback Speed: 1.0x";
PlaybackSpeed.value = 1f;
}
}
#endregion
#region Commands