static void AutoInit() { if (!MidiINPlugin.initialized) { EditorDispatcher.StartThread((a) => { MidiINPlugin.Init(); MidiINPlugin.Refresh(); EditorDispatcher.Dispatch((b) => { MidiINPlugin.RestoreEditorConnections(); midiINInitialized = true; }, new { a = "" }); }, new { a = "" }); } else { midiINInitialized = true; } if (!MidiOUTPlugin.initialized) { EditorDispatcher.StartThread((a) => { MidiOUTPlugin.Init(); MidiOUTPlugin.Refresh(); EditorDispatcher.Dispatch((b) => { MidiOUTPlugin.RestoreEditorConnections(); midiOUTInitialized = true; }, new { a = "" }); }, new { a = "" }); } else { midiOUTInitialized = true; } EditorApplication.update -= EditorUpdate; EditorApplication.update += EditorUpdate; }
static IEnumerator InitMidiIO() { if (!MidiINPlugin.initialized) { MidiINPlugin.Init(); } yield return(new WaitUntil(() => MidiINPlugin.Initialized() )); if (!MidiOUTPlugin.initialized) { MidiOUTPlugin.Init(); } yield return(new WaitUntil(() => MidiOUTPlugin.Initialized() )); forceDefaultMidiIn = settings.forceDefaultMidiIn; defaultMidiIn = settings.defaultMidiIn; forceDefaultMidiOut = settings.forceDefaultMidiOut; defaultMidiOut = settings.defaultMidiOut; if (forceDefaultMidiIn) { if (defaultMidiIn >= 0 && defaultMidiIn < MidiINPlugin.GetDeviceCount()) { MidiINPlugin.ConnectDevice(defaultMidiIn); } } else { MidiINPlugin.RestoreConnections(); if (MidiINPlugin.connectedDevices.Count == 0) { if (defaultMidiIn >= 0 && defaultMidiIn < MidiINPlugin.GetDeviceCount()) { MidiINPlugin.ConnectDevice(defaultMidiIn); } } } if (forceDefaultMidiOut) { if (defaultMidiOut >= 0 && defaultMidiOut < MidiOUTPlugin.GetDeviceCount()) { MidiOUTPlugin.ConnectDevice(defaultMidiOut); } } else { MidiOUTPlugin.RestoreConnections(); if (MidiOUTPlugin.connectedDevices.Count == 0) { if (defaultMidiOut >= 0 && defaultMidiOut < MidiOUTPlugin.GetDeviceCount()) { MidiOUTPlugin.ConnectDevice(defaultMidiOut); } } } }