public void Update() { var hit = RaycastUtils.CastClickRay(settings.TargetLayers); var mousePos = Input.mousePosition; //Do we allow draggin? And Is The target the same from the click start? And has the mouse not moved much? bool isDrag = settings.AllowDragging && (hit.collider == null || hit.collider != mouseDownTarget) && Vector2.Distance(mousePos, mouseDownPosition) > settings.dragStartDistance; //Click Start if (Input.GetMouseButtonDown(settings.Button)) { //mouseDownTime = Time.time; mouseDownPosition = Input.mousePosition; mouseDownRealWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); mouseDownTarget = hit.collider; } //Dragging else if (Input.GetMouseButton(settings.Button)) { if (!isDrag) { if (OnClickHold != null) { OnClickHold(new TargetingArguments(hit.collider, hit.point)); } } else { RaycastHit[] allHits = RaycastUtils.BoxSelect(settings.TargetLayers, mouseDownPosition); if (OnMultiSelectHover != null) { OnMultiSelectHover(allHits.Select(h => new TargetingArguments(h.collider, h.point)).ToArray()); } } } //Released else if (Input.GetMouseButtonUp(settings.Button)) { if (!isDrag) { if (OnClicked != null) { OnClicked(new TargetingArguments(hit.collider, hit.point)); } } else { RaycastHit[] allHits = RaycastUtils.BoxSelect(settings.TargetLayers, mouseDownPosition); if (OnMultiSelect != null) { OnMultiSelect(allHits.Select(h => new TargetingArguments(h.collider, h.point)).ToArray()); } } } else //Just Hovering { if (OnHover != null) { OnHover(new TargetingArguments(hit.collider, hit.point)); } } }