protected sealed override Vector3 GetWorldTranslationDelta(DragTranslation translationInfo, Vector3 sourcePos) { var delta = translationInfo.currentPosition - m_LastHitPos; m_LastHitPos = translationInfo.currentPosition; return(delta); }
protected override void OnTranslationBegin(DragTranslation translationInfo) { Vector3 handlePosition = transform.position; m_LastFramePos = handlePosition; m_HandleStartPos = MathUtility.ProjectPointOnRay(translationInfo.currentPosition, directionRay); Vector3 offset = m_HandleStartPos - handlePosition; m_StartNormalizedOffset = offset / HandleUtility.GetHandleSize(handlePosition); m_StartCenterPosSize = HandleUtility.GetHandleSize(handlePosition); m_StartHandlePosSize = HandleUtility.GetHandleSize(m_HandleStartPos); }
protected override Vector3 GetWorldTranslationDelta(DragTranslation translationInfo, Vector3 sourcePos) { Vector3 projected = MathUtility.ProjectPointOnRay(translationInfo.currentPosition, directionRay); float handleTargetSize = HandleUtility.GetHandleSize(projected); //TODO this isn't true if the target doesn't scale with screen float centerTargetSize = handleTargetSize * m_StartCenterPosSize / m_StartHandlePosSize; Vector3 newOffset = m_StartNormalizedOffset * centerTargetSize; Vector3 newPos = projected - newOffset; var delta = newPos - m_LastFramePos; m_LastFramePos = newPos; m_HandleStartPos = projected; return(delta); }
/// <summary> /// Get the delta of the current translation. The delta is in world space. /// </summary> /// <param name="translationInfo">The information of the drag.</param> /// <param name="sourcePos">The original position of the handle when the translation was started.</param> /// <returns>The delta since last translation in world space.</returns> protected abstract Vector3 GetWorldTranslationDelta(DragTranslation translationInfo, Vector3 sourcePos);
/// <summary> /// Called when a translation ends. /// </summary> /// <param name="translationInfo">The last screen drag information.</param> protected virtual void OnTranslationEnd(DragTranslation translationInfo) { }
/// <summary> /// Called when a translation begins. /// </summary> /// <param name="translationInfo">The initial screen drag information.</param> protected virtual void OnTranslationBegin(DragTranslation translationInfo) { }
protected override void OnTranslationEnd(DragTranslation translationInfo) { }
protected sealed override void OnTranslationBegin(DragTranslation translationInfo) { m_LastHitPos = translationInfo.currentPosition; }