private void RequestDragPickable(Vector3 fingerDownPos)
        {
            Vector3   intersectionPoint = Vector3.zero;
            Component pickedCollider    = GetClosestColliderAtScreenPoint(fingerDownPos, out intersectionPoint);

            if (pickedCollider != null && SelectedColliders.Contains(pickedCollider))
            {
                RequestDragPickable(pickedCollider, fingerDownPos, intersectionPoint);
            }
        }
        /// <summary>
        /// Method to deselect the given collider.
        /// In case the collider hasn't been selected before, the method returns false.
        /// </summary>
        private bool Deselect(Component colliderComponent)
        {
            bool wasRemoved = SelectedColliders.Remove(colliderComponent);

            if (wasRemoved == true)
            {
                OnSelectedColliderChanged(SelectionAction.Deselect, colliderComponent.GetComponent <MobileTouchPickable>());
            }
            return(wasRemoved);
        }
        /// <summary>
        /// Method to deselect all currently selected colliders.
        /// </summary>
        /// <returns></returns>
        public int DeselectAll()
        {
            SelectedColliders.RemoveAll(item => item == null);
            int colliderCount = SelectedColliders.Count;

            foreach (Component colliderComponent in SelectedColliders)
            {
                OnSelectedColliderChanged(SelectionAction.Deselect, colliderComponent.GetComponent <MobileTouchPickable>());
            }
            SelectedColliders.Clear();
            return(colliderCount);
        }
        private void Select(Component colliderComponent, bool isDoubleClick, bool isLongTap)
        {
            MobileTouchPickable mobileTouchPickable = colliderComponent.GetComponent <MobileTouchPickable>();

            if (mobileTouchPickable != null)
            {
                if (SelectedColliders.Contains(colliderComponent) == false)
                {
                    SelectedColliders.Add(colliderComponent);
                }
            }
            OnSelectedColliderChanged(SelectionAction.Select, mobileTouchPickable);
            OnSelectedColliderChangedExtended(SelectionAction.Select, mobileTouchPickable, isDoubleClick, isLongTap);
        }
        private void RequestDragPickable(Component colliderComponent, Vector2 fingerDownPos, Vector3 intersectionPoint)
        {
            if (requireLongTapForMove == true && isSelectedViaLongTap == false)
            {
                return;
            }

            CurrentlyDraggedPickable = null;
            bool isDragStartedOnSelection = colliderComponent != null && SelectedColliders.Contains(colliderComponent);

            if (isDragStartedOnSelection == true)
            {
                MobileTouchPickable mobileTouchPickable = colliderComponent.GetComponent <MobileTouchPickable>();
                if (mobileTouchPickable != null)
                {
                    mobileTouchCam.OnDragSceneObject(); //Lock camera movement.
                    CurrentlyDraggedPickable          = mobileTouchPickable;
                    currentlyDraggedTransformPosition = CurrentlyDraggedTransform.position;

                    invokeMoveStartedOnDrag = true;
                    currentDragStartPos     = CurrentlyDraggedTransform.position;
                    selectionPositionOffsets.Clear();
                    foreach (Component selectionComponent in SelectedColliders)
                    {
                        selectionPositionOffsets.Add(selectionComponent, currentDragStartPos - selectionComponent.transform.position);
                    }

                    draggedTransformOffset       = Vector3.zero;
                    draggedTransformHeightOffset = Vector3.zero;
                    draggedItemCustomOffset      = Vector3.zero;

                    //Find offset of item transform relative to ground.
                    Vector3 groundPosCenter     = Vector3.zero;
                    Ray     groundScanRayCenter = new Ray(CurrentlyDraggedTransform.position, -mobileTouchCam.RefPlane.normal);
                    bool    rayHitSuccess       = mobileTouchCam.RaycastGround(groundScanRayCenter, out groundPosCenter);
                    if (rayHitSuccess == true)
                    {
                        draggedTransformHeightOffset = CurrentlyDraggedTransform.position - groundPosCenter;
                    }
                    else
                    {
                        groundPosCenter = CurrentlyDraggedTransform.position;
                    }

                    draggedTransformOffset     = groundPosCenter - intersectionPoint;
                    itemInitialDragOffsetWorld = (ComputeDragPosition(fingerDownPos, SnapToGrid) - CurrentlyDraggedTransform.position);
                }
            }
        }
 private void InputControllerOnDragStart(Vector3 clickPosition, bool isLongTap)
 {
     if (isLongTap == true && touchInputController.LongTapStartsDrag == true)
     {
         Vector3   intersectionPoint;
         Component newCollider = GetClosestColliderAtScreenPoint(clickPosition, out intersectionPoint);
         if (newCollider != null)
         {
             MobileTouchPickable newPickable = newCollider.GetComponent <MobileTouchPickable>();
             if (newPickable != null)
             {
                 if (SelectedColliders.Contains(newCollider) == false)
                 {
                     SelectColliderInternal(newCollider, false, isLongTap);
                 }
                 else
                 {
                     isSelectedViaLongTap = isLongTap;
                 }
                 RequestDragPickable(clickPosition);
             }
         }
     }
 }