Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        byte tmp = 0;

        if (knob)
        {
            if (direction == Direction.X)
            {
                tmp = (byte)(knob.GetX() * range);
            }
            else if (direction == Direction.Y)
            {
                tmp = (byte)(knob.GetY() * range);
            }

            if (tmp != value)
            {
                value = tmp;
                CCMessage();
            }
        }
        else
        {
            if (!knobErrorDisplayed)
            {
                Debug.Log("No knob was assigned to MIDI CC handler" + name + "!");
            }
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (grabbingHand)
        {
            UpdateHandPosition(grabbingHand);
        }

        bool updated = false;

        // Retrieve controls coordinates first, and set the knob to their position.
        if (xControl != null)
        {
            float tmp = xValue;
            xValue = xControl.GetX();

            if (tmp != xValue)
            {
                updated = true;
            }
        }
        if (yControl != null)
        {
            float tmp = yValue;
            yValue = yControl.GetY();

            if (tmp != yValue)
            {
                updated = true;
            }
        }

        // Only then set the knob to the hand position (priority is hand > controls).
        if (pressed)
        {
            if (handX > maxX)
            {
                xValue = 1;
            }
            else if (handX < minX)
            {
                xValue = 0;
            }
            else
            {
                xValue = (handX - minX) / (maxX - minX);
            }

            if (handY > maxY)
            {
                yValue = 1;
            }
            else if (handY < minY)
            {
                yValue = 0;
            }
            else
            {
                yValue = (handY - minY) / (maxY - minY);
            }

            updated = true;
        }

        if (updated)
        {
            SlideTo(xValue, yValue);
        }
    }