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

23 lines
565 B
C#
Raw Normal View History

2019-10-05 12:18:52 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace cylvester
{
public class PositionBind : MonoBehaviour
{
[SerializeField,Range(1,16)] private int channel = 1;
public void OnControlMessageReceived(ControlMessage mes)
{
if (mes.Channel == channel - 1)
{
var x = (mes.ControlNumber - 64) / 10f;
var y = (mes.ControlValue - 64) / 10f;
transform.position = new Vector3(x, y, 0f);
}
}
}
}