soundvision/UnityProject/Assets/Scripts/Math/Threshold.cs
2019-10-07 18:53:36 +02:00

24 lines
No EOL
558 B
C#

using UnityEngine;
using UnityEngine.Events;
namespace cylvester
{
public class Threshold : MonoBehaviour
{
[SerializeField] private float threshold;
[SerializeField] private UnityEvent thresholdExceeded;
private bool over_;
public void OnValueReceived(float value)
{
if (value > threshold && !over_)
{
over_ = true;
thresholdExceeded.Invoke();
}
if (value < threshold && over_)
over_ = false;
}
}
}