soundvision/UnityProject/Assets/Scripts/PdConnection/PdNoiseBind.cs
2019-10-29 18:52:09 +01:00

29 lines
No EOL
690 B
C#

using UnityEngine;
using UnityEngine.Events;
namespace cylvester
{
[System.Serializable]
public class NoiseEvent : UnityEvent<float>
{
}
public class PdNoiseBind : MonoBehaviour
{
[SerializeField] private PdBackend pdbackend;
[SerializeField, Range(1, 16)] private int channel = 1;
[SerializeField] private NoiseEvent noiseLevelChanged;
private float noise_;
void Update()
{
var noise = pdbackend.NoiseArray.Data[channel - 1];
if (noise_ != noise)
{
noise_ = noise;
noiseLevelChanged.Invoke(noise_);
}
}
}
}