Exemple #1
0
        protected override void OnHandleDragging(HandleEventData eventData)
        {
            var worldPosition = GetRayPoint(eventData);

            eventData.deltaPosition = worldPosition - m_LastPosition;
            m_LastPosition          = worldPosition;

            base.OnHandleDragging(eventData);
        }
        protected override void OnHandleDragStarted(HandleEventData eventData)
        {
            var planeEventData = eventData as PlaneHandleEventData;

            m_LastPosition = planeEventData.raycastHitWorldPosition;

            m_Plane.SetNormalAndPosition(transform.forward, transform.position);

            base.OnHandleDragStarted(eventData);
        }
Exemple #3
0
        protected override void OnHandleDragStarted(HandleEventData eventData)
        {
            var sphereEventData = eventData as SphereHandleEventData;

            m_CurrentRadius = sphereEventData.raycastHitDistance;

            m_LastPosition = GetRayPoint(eventData);

            m_ScrollRate = kInitialScrollRate;

            base.OnHandleDragStarted(eventData);
        }
Exemple #4
0
        protected override void OnHandleDragStarted(HandleEventData eventData)
        {
            Transform rayOrigin = eventData.rayOrigin;

            var radialEventData = eventData as RadialHandleEventData;

            m_LastPosition    = radialEventData.raycastHitWorldPosition;
            m_LastDragForward = rayOrigin.forward;

            m_Plane.SetNormalAndPosition(rayOrigin.forward, transform.position);

            m_DragTangent = Vector3.Cross(transform.up, startDragPosition - transform.position);

            UpdateHandleTip(radialEventData);

            base.OnHandleDragStarted(eventData);
        }
Exemple #5
0
        protected override void OnHandleDragStarted(HandleEventData eventData)
        {
            var linearEventData = eventData as LinearHandleEventData;

            m_LastPosition = linearEventData.raycastHitWorldPosition;

            // Create a plane through the axis that rotates to avoid being parallel to the ray, so that you can prevent
            // intersections at infinity
            var forward = Quaternion.Inverse(transform.rotation) * (eventData.rayOrigin.position - transform.position);

            forward.z = 0;
            m_Plane.SetNormalAndPosition(transform.rotation * forward.normalized, transform.position);

            UpdateHandleTip(linearEventData);

            base.OnHandleDragStarted(eventData);
        }
Exemple #6
0
        protected override void OnHandleDragging(HandleEventData eventData)
        {
            Transform rayOrigin     = eventData.rayOrigin;
            Vector3   worldPosition = m_LastPosition;

            // Continue to rotate plane, so that the ray direction isn't parallel to the plane
            var forward = Quaternion.Inverse(transform.rotation) * (rayOrigin.position - transform.position);

            forward.z = 0;
            m_Plane.SetNormalAndPosition(transform.rotation * forward.normalized, transform.position);

            float distance = 0f;
            Ray   ray      = new Ray(rayOrigin.position, rayOrigin.forward);

            if (m_Plane.Raycast(ray, out distance))
            {
                worldPosition = ray.GetPoint(Mathf.Min(distance, kMaxDragDistance));
            }

            var linearEventData = eventData as LinearHandleEventData;

            linearEventData.raycastHitWorldPosition = worldPosition;

            var deltaPosition = worldPosition - m_LastPosition;

            m_LastPosition = worldPosition;

            deltaPosition           = transform.InverseTransformVector(deltaPosition);
            deltaPosition.x         = 0;
            deltaPosition.y         = 0;
            deltaPosition           = transform.TransformVector(deltaPosition);
            eventData.deltaPosition = deltaPosition;

            UpdateHandleTip(linearEventData);

            base.OnHandleDragging(eventData);
        }
Exemple #7
0
 protected override void OnHandleHoverEnded(HandleEventData eventData)
 {
     UpdateHandleTip(eventData as RadialHandleEventData);
     base.OnHandleHoverEnded(eventData);
 }
Exemple #8
0
 protected override void OnHandleHovering(HandleEventData eventData)
 {
     UpdateHandleTip(eventData as RadialHandleEventData);
 }
Exemple #9
0
 protected override void OnHandleHoverStarted(HandleEventData eventData)
 {
     UpdateHandleTip(eventData as LinearHandleEventData);
     base.OnHandleHoverStarted(eventData);
 }
Exemple #10
0
 /// <summary>
 /// Override to modify event data prior to raising event (requires calling base method at the end)
 /// </summary>
 protected virtual void OnDoubleClick(HandleEventData eventData)
 {
     doubleClick(this, eventData);
 }
Exemple #11
0
 /// <summary>
 /// Override to modify event data prior to raising event (requires calling base method at the end)
 /// </summary>
 protected virtual void OnHandleDragEnded(HandleEventData eventData)
 {
     dragEnded(this, eventData);
 }
Exemple #12
0
 /// <summary>
 /// Override to modify event data prior to raising event (requires calling base method at the end)
 /// </summary>
 protected virtual void OnHandleDragging(HandleEventData eventData)
 {
     dragging(this, eventData);
 }
Exemple #13
0
 /// <summary>
 /// Override to modify event data prior to raising event (requires calling base method at the end)
 /// </summary>
 protected virtual void OnHandleHoverEnded(HandleEventData eventData)
 {
     hoverEnded(this, eventData);
 }