예제 #1
0
    public void OnDrag(OnDragEventArg args)
    {
        if (args.HitObject == gameObject)
        {
            Ray     r          = Camera.main.ScreenPointToRay(args.TargetFinger.position);
            Vector3 worldPoint = r.GetPoint(10);

            targetPosition     = worldPoint;
            transform.position = worldPoint;
        }
    }
예제 #2
0
    private void OnDrag(object sender, OnDragEventArg e)
    {
        Vector2 delta = e.TargetFinger.deltaPosition;

        delta = delta / Screen.dpi;

        Vector3 change = (Vector3)delta * Player.instance.stats.cameraSpeed;

        transform.position += change;

        widthEdge  = (playableScreen.rect.width * playableScreen.lossyScale.x - screen.rect.width * screen.lossyScale.x) / 2;
        heightEdge = (playableScreen.rect.height * playableScreen.lossyScale.y - screen.rect.height * screen.lossyScale.y) / 2;

        float width  = Mathf.Clamp(transform.position.x, -widthEdge, widthEdge);
        float height = Mathf.Clamp(transform.position.y, -heightEdge, heightEdge);

        transform.position = new Vector3(width, height, transform.position.z);
    }
예제 #3
0
    private void FireDragEvent()
    {
        //Debug.Log($"Dragging {trackedFinger1.position.ToString()}");
        GameObject hitObj = GetHit(trackedFinger1.position);

        OnDragEventArg args = new OnDragEventArg(trackedFinger1, hitObj);

        if (OnDrag != null)
        {
            OnDrag(this, args);
        }

        if (hitObj != null)
        {
            IDragged iDrag = hitObj.GetComponent <IDragged>();
            if (iDrag != null)
            {
                iDrag.OnDrag(args);
            }
        }
    }