// Mouse Button Up -> Stop dragging and drop the disk void OnMouseUp() { if (_isMouseDragging) { Vector2 end = Vector2.zero; // Restore sorting layer _renderer.sortingLayerName = _layerName; // Restore a no-trigger collider, we need this to trigger the Enter/Exit of a stick + falling animation _collider.isTrigger = false; // Stop dragging _isMouseDragging = false; // Restore opacity on the stick disks when releasing the mouse if (_overedStick != null) { _overedStick.SetDisksTransparent(false, this); } // The disk just got dropped on a stick if (_overedStick != null && _overedStick.CanAddDisk(this)) { if (IsCurrentStick(_overedStick)) { // Dropping the disk on the same stick, animate the movement towards the initial position end = _initialPosition; OnDropped(false); } else { // Aligh stick to the center of the stick and disable further dragging end = GetEndMovementPosition(_overedStick.GetComponent <Collider2D>()); // Remove the disk from the previous stick currentStick.RemoveTopDisk(); // Add the disk to the new stick _overedStick.AddDisk(this); // Store the stick on which the disk has been dropped as backup //currentStick = _stickElement; // Raise event for dropping OnDropped(true); } } else { // Disk was dropped outside a stick or on a smaller disk end = _initialPosition; OnDropped(false); } // Start movement of the disk on the top of the designed stick StartCoroutine(DropDisk(end)); } }