49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public class MusicPlayer : MonoBehaviour
|
|
{
|
|
public bool isPlaying;
|
|
public AudioSource audioSource;
|
|
|
|
private void Update()
|
|
{
|
|
if (isPlaying)
|
|
{
|
|
EditorManager.instance.songInformation.songTime = EditorManager.instance.musicPlayer.audioSource.time;
|
|
}
|
|
}
|
|
|
|
public void PlayMusic()
|
|
{
|
|
|
|
isPlaying = !isPlaying;
|
|
Trail.SetAllTrails(true, false);
|
|
EditorManager.instance.songInformation.songTime = audioSource.time;
|
|
if (isPlaying) audioSource.Play();
|
|
else audioSource.Pause();
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |