void IBeginDragHandler.OnBeginDrag(PointerEventData eventData) { var pointerPosition = eventData.position; if (TestPlanetTransformHandle(pointerPosition, out _planetHandle)) { _dragging = true; _dragInitPosition = pointerPosition; _planetHandle.SetHandling(true); _initPlanetRotation = _planetHandle.Planet.rotation; _initPlanetLocalRotation = _planetHandle.Planet.localRotation; var dir = Quaternion.Euler(0, 0, 0) * Vector3.forward; var worldDir = _mainCamera.transform.rotation * dir; var localDir = Quaternion.Inverse(_initPlanetRotation) * worldDir; _initPlanetDirection = localDir; } }
void IEndDragHandler.OnEndDrag(PointerEventData eventData) { _dragging = false; _planetHandle?.SetHandling(false); _planetHandle = null; }