예제 #1
0
    public void OnDeviceClick(MidiSelectionUIDeviceButton button)
    {
        Debug.Log("Device : " + button.device.ToString() + " " + button.text.text);
        if (button.connected)
        {
            switch (button.device)
            {
            case MidiSelectionUIDeviceButton.Device.IN:
                MidiINPlugin.DisconnectDeviceByName(button.text.text);
                button.image.color = disconnectedColor;
                button.connected   = false;
                MidiINPlugin.StoreConnections();
                break;

            case MidiSelectionUIDeviceButton.Device.OUT:
                MidiOUTPlugin.DisconnectDeviceByName(button.text.text);
                button.image.color = disconnectedColor;
                button.connected   = false;
                MidiOUTPlugin.StoreConnections();
                break;
            }
        }
        else
        {
            switch (button.device)
            {
            case MidiSelectionUIDeviceButton.Device.IN:
                if (MidiINPlugin.ConnectDeviceByName(button.text.text) != null)
                {
                    button.image.color = connectedColor;
                    button.connected   = true;
                    MidiINPlugin.StoreConnections();
                }
                break;

            case MidiSelectionUIDeviceButton.Device.OUT:
                if (MidiOUTPlugin.ConnectDeviceByName(button.text.text) != null)
                {
                    button.image.color = connectedColor;
                    button.connected   = true;
                    MidiOUTPlugin.StoreConnections();
                }
                break;
            }
        }
    }