52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
|
|
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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|