Closed soniccustard closed 7 years ago
This doesn't work because the first invocation of the NoteOn
delegate happens inside the first invocation of GetKeyDown
.
Workaround: Call GetKeyDown(0)
before it. It invokes the NoteOn
delegate and you'll get a correct noteNumber
. Then, you can do GetKeyDown(noteNumber)
correctly.
I'm closing this issue. Please feel free to reopen if the workaround doesn't work.
Thank you so much! You've made my program possible!
Hey, I'm trying to write a script in Unity that allows it to respond to any MIDI note, not just the specified one. In my program it creates an object each time you press a key. It works perfectly with the key numbers assigned, but not when I try it like this. Also the GUI number instantly changes with a key press, but the makeCube bit doesn't do anything until the second press of the same key.
public class DelegateTester : MonoBehaviour { public GameObject cube; int noteNumber; public Vector3 ObjectSpawnPosition; string noteGUI;
}