keijiro / MidiJack

MIDI input plugin for Unity
695 stars 113 forks source link

MIDI controller unity build issue #17

Closed FigJig closed 7 years ago

FigJig commented 7 years ago

Hey, thanks for sharing this!

I'm having an issue though with my MIDI controller (Korg nanoKONTROL2) where within the Unity engine I can change values of a slider using a knob/encoder, but when I make a build it no longer works. This is the code:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using MidiJack;

public class CityPower : MonoBehaviour {

public GameObject playerPowerBar;
public Image transferPower;

Slider cityPowerSlider;

// Use this for initialization
void Start () {
    cityPowerSlider = GetComponent<Slider>();
}

// Update is called once per frame
void Update () {

    var s = MidiMaster.GetKnob(16);
    var d = MidiMaster.GetKnob(32);

    cityPowerSlider.value = s;

    if (s == 0.0)
    {
        cityPowerSlider.maxValue = 0.0f;
        transferPower.GetComponent<Image>().enabled = true;
    }

    if (s == 0.0 & d == 1.0)
    {
        playerPowerBar.gameObject.GetComponent<PowerBar>().enabled = true;
        Destroy(gameObject);
    }

}

}

Anyone know why this would be happening? Please let me know if you need additional info.

Thanks.