Timeline
This commit is contained in:
52
Assets/Scripts/DynamicUI/Timeline/MusicPlayer.cs
Normal file
52
Assets/Scripts/DynamicUI/Timeline/MusicPlayer.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class MusicPlayer : MonoBehaviour
|
||||
{
|
||||
public bool isPlaying;
|
||||
public AudioSource audioSource;
|
||||
|
||||
public Button playButton;
|
||||
public Button pauseButton;
|
||||
public Button stopButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
playButton.onClick.AddListener(PlayMusic);
|
||||
pauseButton.onClick.AddListener(PauseMusic);
|
||||
stopButton.onClick.AddListener(StopMusic);
|
||||
}
|
||||
|
||||
public void PlayMusic()
|
||||
{
|
||||
isPlaying = true;
|
||||
Trail.SetAllTrails(true, false);
|
||||
EditorManager.instance.songInformation.songTime = audioSource.time;
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
public void PauseMusic()
|
||||
{
|
||||
isPlaying = false;
|
||||
Trail.SetAllTrails(false, false);
|
||||
EditorManager.instance.songInformation.songTime = audioSource.time;
|
||||
audioSource.Pause();
|
||||
}
|
||||
|
||||
public void StopMusic()
|
||||
{
|
||||
isPlaying = false;
|
||||
Trail.SetAllTrails(false, true);
|
||||
EditorManager.instance.songInformation.songTime = 0;
|
||||
audioSource.Stop();
|
||||
EditorManager.instance.uiManager.timeline.timePointerModule.SetRange(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user