protected override void DragUpdate(InteractiveHandle target, DragUpdateInfo info) { if (target != ownerHandle) { return; } var delta = GetWorldTranslationDelta(info.translation, m_InitialPosWorld); m_TotalTranslation = m_TotalTranslation + delta; m_CurrentDirection = delta.normalized; var inverseRotation = Quaternion.Inverse(transform.rotation); if (translationUpdated != null) { translationUpdated.Invoke(new TranslationUpdateInfo( //World new TranslationInfo( m_InitialPosWorld, delta, m_TotalTranslation, m_CurrentDirection), //Local new TranslationInfo( m_InitialPosLocal, inverseRotation * delta, inverseRotation * m_TotalTranslation, inverseRotation * m_CurrentDirection) )); } }
protected override void DragUpdate(InteractiveHandle target, DragUpdateInfo info) { if (target != ownerHandle) { return; } var currentDir = info.translation.currentPosition - transform.position; var deltaAngle = Vector3.SignedAngle(m_LastDirection, currentDir, m_Normal); m_TotalAngle += deltaAngle; m_LastDirection = currentDir; if (rotationUpdated != null) { rotationUpdated.Invoke(new RotationUpdateInfo( new RotationInfo( // World m_TotalAngle, deltaAngle, m_Normal), new RotationInfo( // Local m_TotalAngle, deltaAngle, transform.worldToLocalMatrix.rotation * m_Normal))); } }
public void Update(Vector3 hitPos) { switch (m_State) { case State.Hovering: { var eventData = new HoverUpdateInfo(); foreach (var behaviour in TakeSnapshot(m_Context.GetHandleBehaviours())) { if (behaviour == null) { continue; } behaviour.DoHoverUpdate(m_ActiveHandle, eventData); } break; } case State.Dragging: { var eventData = new DragUpdateInfo(new DragTranslation( m_StartDragPosition, hitPos, hitPos - m_LastFramePosition)); foreach (var behaviour in TakeSnapshot(m_Context.GetHandleBehaviours())) { if (behaviour == null) { continue; } behaviour.DoDragUpdate(m_ActiveHandle, eventData); } break; } } }