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

29 lines
488 B
C#
Raw Normal View History

2018-11-20 20:10:49 +01:00
using UnityEngine;
namespace Fie.Utility
{
public class FieUtilAutoAudioTimeScaler : MonoBehaviour
{
private float _defaultPitch = 1f;
private AudioSource _audioSource;
private void Awake()
{
_audioSource = base.gameObject.GetComponent<AudioSource>();
if (_audioSource != null)
{
_defaultPitch = _audioSource.pitch;
}
}
private void Update()
{
if (!(_audioSource == null))
{
_audioSource.pitch = _defaultPitch * Time.timeScale;
}
}
}
}