// Update is called once per frame void LateUpdate() { if (dragging != null && Input.GetMouseButtonUp(0)) { if (dragging.onRelease != null) { dragging.onRelease(); } dragging = null; } if (dragging == this) { transform.position = Input.mousePosition; } }