Example #1
0
    private void OnMouseDown()
    {
        // Initialize the script by retrieving them from the ones attached to the game object
        moveAction    = GetComponent <IMoveItem>();
        mousePosition = GetComponent <IMousePosition>();

        rb.isKinematic = true;
        offset         = gameObject.transform.position - mousePosition.GetMousePosition();
        prevMousePos   = mousePosition.GetMousePosition();
    }
Example #2
0
    private void OnMouseDrag()
    {
        SessionEvents.current.ItemDragAny();
        // Compute the item z-coordinate relative to its current position
        Vector3 curMousePos = mousePosition.GetMousePosition();

        // If the the mouse is going upward, we increase the depth.
        // Otherwise if it is negative we just decrease it.
        // In case it is 0 we do not modify the depth, it means there was no mouse motion

        /*
         * float yDiff = curMousePos.y - prevMousePos.y;
         * // Debug.Log(yDiff);
         * if (yDiff > 0) {
         *  curMousePos.z += yDiff;
         * } else if (yDiff < 0) {
         *  curMousePos.z -= yDiff;
         * }
         *
         * curMousePos.z = curMousePos.z;
         */


        moveAction.MoveItem(gameObject, curMousePos + offset);
        prevMousePos = curMousePos;// Quit track of the current position for the next iteration.
    }