public static void Shutdown() { if (!_initialized) { return; } for (int i = 0; i < devices.Length; i++) { MidiInternal.rtmidi_close_port(devices[i]); MidiInternal.rtmidi_in_free(devices[i]); devices[i] = (IntPtr)0; } _initialized = false; OnNextNote = null; EditorApplication.update = null; EditorApplication.playModeStateChanged -= EditorApplicationOnplayModeStateChanged; }