NGUI UIButton Event question

Hi,

I have created 4 buttons which represent 4 direction arrows, Left, Right, Forward and Backwards.

I have a OnPress(bool isPress) function which checks which of the button were pressed and I send information about my x and y axis.

This is the function:

    private static int x = 0;
    private static int y = 0;
    private string currentArrow = "none";
    private Vector2 currentPos = Vector2.zero;

    void OnPress(bool isDown)
    {
        Debug.Log("Called " + gameObject.name + " press state: "+isDown);
        if (isDown)
        {
            switch (gameObject.name)
            {
                case "Up":
                    y = 1;
                    x = 0;
                    break;
                case "Down":
                    y = -1;
                    x = 0;
                    break;
                case "Right":
                    x = 1;
                    y = 0;
                    break;
                case "Left":
                    x = -1;
                    y = 0;
                    break;
                default:
                    Debug.Log("Error in name");
                    break;
            }
            currentArrow = gameObject.name;
            currentPos = gameObject.transform.position;
        }
        else
        {
            x = 0;
            y = 0;
        }

        SetValues(x, y);
    }

This works just fine,

However, when my mouse is pressing a button, and I want it to move while it is pressed, to another collider, and activate it, I can’t since I didn’t release the last button.

Any idea on how to do it?

I’ve tried to send messages by myself to OnPress with a false parameter to do it manually, but it still doesn’t work right…

I’ve also tried to use OnHover, but I work with an android device, so it’s irrelevant…

To enable this functionality, go to the UICamera and uncheck the value “Sticky Press”. This enables press events for multiple GameObjects instead of just the original pressed one. It is explained better in the comments for the value in the UICamera script.