soundvision/UnityProject/Assets/Scenes/Examples/MIDI/script/PositionBind.cs

21 lines
489 B
C#
Raw Normal View History

2019-10-26 20:15:30 +00:00
using UnityEngine;
2019-10-05 12:18:52 +00:00
namespace cylvester
{
public class PositionBind : MonoBehaviour
{
[SerializeField,Range(1,16)] private int channel = 1;
2019-10-26 20:15:30 +00:00
public void OnMidiMessageReceived(MidiMessage mes)
2019-10-05 12:18:52 +00:00
{
2019-10-26 20:15:30 +00:00
if (mes.Status - 176 == channel - 1)
2019-10-05 12:18:52 +00:00
{
2019-10-26 20:15:30 +00:00
var x = (mes.Data1 - 64) / 10f;
var y = (mes.Data2 - 64) / 10f;
2019-10-05 12:18:52 +00:00
transform.position = new Vector3(x, y, 0f);
}
}
}
}