FiE-Game/Assets/Scripts/Fie/Utility/FieBgmBehaviour.cs

33 lines
591 B
C#
Raw Normal View History

2018-11-20 20:10:49 +01:00
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;
}
}
}
}