mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-27 15:57:59 +01:00
33 lines
591 B
C#
33 lines
591 B
C#
|
using UnityEngine;
|
||
|
|
||
|
namespace Fie.Utility
|
||
|
{
|
||
|
[RequireComponent(typeof(AudioSource))]
|
||
|
public class FieBgmBehaviour : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField]
|
||
|
private float _startTime;
|
||
|
|
||
|
[SerializeField]
|
||
|
private float _loopTime;
|
||
|
|
||
|
[SerializeField]
|
||
|
private float _endTime;
|
||
|
|
||
|
private AudioSource _currentBgmSource;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
_currentBgmSource = GetComponent<AudioSource>();
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
if (_currentBgmSource != null && _currentBgmSource.isPlaying && _currentBgmSource.time >= _endTime)
|
||
|
{
|
||
|
_currentBgmSource.time = _loopTime;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|