コード例 #1
0
    protected override BaseInput.FingerPhase GetPhase(BaseInput.Finger finger)
    {
        int button = finger.Index;

        // mouse button down?
        if (Input.GetMouseButton(button))
        {
            // did we just press it?
            if (Input.GetMouseButtonDown(button))
            {
                Debug.Log("[MouseInput]: MouseDown");
                return(FingerPhase.Began);
            }

            // find out if the mouse has moved since last update
            Vector3 delta = GetPosition(finger) - finger.Position;

            if (delta.sqrMagnitude < 1.0f)
            {
                return(FingerPhase.Stationary);
            }

            Debug.Log("[MouseInput]: MouseMove");
            return(FingerPhase.Moved);
        }

        // did we just release the button?
        if (Input.GetMouseButtonUp(button))
        {
            Debug.Log("[MouseInput]: MouseUp");
            return(FingerPhase.Ended);
        }

        return(FingerPhase.None);
    }
コード例 #2
0
    protected override BaseInput.FingerPhase GetPhase(BaseInput.Finger finger)
    {
        if (HasValidTouch(finger))
        {
            UnityEngine.Touch touch = GetTouch(finger);

            switch (touch.phase)
            {
            case UnityEngine.TouchPhase.Began:
                return(FingerPhase.Began);

            case UnityEngine.TouchPhase.Moved:
                return(FingerPhase.Moved);

            case UnityEngine.TouchPhase.Stationary:
                return(FingerPhase.Stationary);

            default:
                return(FingerPhase.Ended);
            }
        }

        return(FingerPhase.None);
    }