soundvision/UnityProject/Assets/Scripts/Math/Threshold.cs

25 lines
579 B
C#
Raw Normal View History

2019-10-07 16:53:36 +00:00
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)
{
2019-10-07 22:03:16 +00:00
Debug.Log(value);
2019-10-07 16:53:36 +00:00
if (value > threshold && !over_)
{
over_ = true;
thresholdExceeded.Invoke();
}
if (value < threshold && over_)
over_ = false;
}
}
}