예제 #1
0
    private IEnumerator TrackButtonPress(String buttonName, PickupController.Slot slot, Vector2 startPos, float startTime)
    {
        bool isDrag = false;

        pickups.TouchPickup(slot);

        //Wait for the button to be released
        while (CrossPlatformInputManager.GetButton(buttonName))
        {
            //If the button is not released within the threshold time then this touch is treated as a drag
            if (allowDraggingPickups)
            {
                if (!isDrag && Time.time - startTime > pickupTimeThreshold)
                {
                    isDrag = true;
                    pickups.StartDragging(slot, CrossPlatformInputManager.GetLastKnownPos(buttonName));
                }
                if (isDrag)
                {
                    pickups.Drag(CrossPlatformInputManager.GetLastKnownPos(buttonName));
                }
            }
            yield return(new WaitForFixedUpdate());
        }
        if (!isDrag)
        {
            pickups.UsePickup(slot);
        }
        else
        {
            pickups.EndDrag();
        }
    }