Exemplo n.º 1
0
    void CheckCustomGestures()
    {
        GestureList gestures = controller.GetCustomGestures();

        for (int i = 0; i < gestures.Count; i++)
        {
            Gesture gesture = gestures[i];
            switch (gesture.Type)
            {
            case Gesture.GestureType.TYPESCREENTAP:
                MoveFoward();
                break;

            case Gesture.GestureType.TYPEKEYTAP:
                KeyTapGesture keyTapGesture = new KeyTapGesture(gesture);
                Vector3       vector        = keyTapGesture.Position.ToUnityScaled();
                hudScript.PressButton(controller.transform.TransformPoint(vector));
                break;

            case Gesture.GestureType.TYPESWIPE:
                SwipeGesture swipeGesture = new SwipeGesture(gesture);
                Rotate90(swipeGesture.Direction.x);
                break;

            default:
                break;
            }
        }
    }
Exemplo n.º 2
0
    private void TapGestures()
    {
        GestureList gestures = controller.GetCustomGestures();

        for (int i = 0; i < gestures.Count; i++)
        {
            Gesture gesture = gestures[i];
            Vector3 vect    = new Vector3();
            if (gesture.Type == ScreenTapGesture.ClassType())
            {
                //Debug.Log ("tap");
                ScreenTapGesture screenTapGesture = new ScreenTapGesture(gesture);
                vect = screenTapGesture.Position.ToUnityScaled();
            }
            if (gesture.Type == KeyTapGesture.ClassType())
            {
                //Debug.Log ("key");
                KeyTapGesture screenTapGesture = new KeyTapGesture(gesture);
                vect = screenTapGesture.Position.ToUnityScaled();
            }
            vect = controller.transform.TransformPoint(vect);

            foreach (Button button in buttons)
            {
                Vector3[]     corners   = new Vector3 [4];
                RectTransform rectTrans = button.gameObject.GetComponent <RectTransform>();
                rectTrans.GetWorldCorners(corners);
                if (ContainInWorld(corners, vect))
                {
                    button.onClick.Invoke();
                }
            }
        }
    }