void Update()
    {
        // If fingers are within hovering distance of the object
        if (intObj.isPrimaryHovered)
        {
            currDistance = intObj.primaryHoverDistance;
            // If your fingers are within the objects proximity and the button isn't already being held down
            if (intObj.primaryHoverDistance < proximityDistance && state == null)
            {
                state = "Active";

                // Call Button Pressed Function
                buttonPress bPScr = gameObject.GetComponent <buttonPress>();
                bPScr.ButtonPressed();
            }
            // If fingers have left the objects proximity
            else if (state == "Active" && intObj.primaryHoverDistance > proximityDistance)
            {
                state = null;

                // Call Button UnPressed Function
                buttonPress bPScr = gameObject.GetComponent <buttonPress>();
                bPScr.ButtonUnPressed();
            }
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider collider)
    {
        //Detect fingers touching object
        if (isHands == true)
        {
            // If object not active currently
            if (state == null)
            {
                for (int i = 0; i < collidingObjects.Length; i++)
                {
                    // If colliding object is the same trigger object
                    if (collider.gameObject.GetInstanceID() == collidingObjects [i].GetInstanceID())
                    {
                        state      = "Active";
                        isTouching = true;

                        if (gameObject.name == "2DButton")
                        {
                            // Call Button Pressed Function
                            buttonPress bPScr = gameObject.GetComponent <buttonPress> ();
                            bPScr.ButtonPressed();
                        }                        //PLACE ELSE IF CONDITION(S) HERE TO ADD MORE FEATURES FOR DIFFERENT TYPES OF BUTTONS
                    }
                }
            }
        }
    }