public void DrawHandles(Vector3 ownPosition)
        {
            if (connectedTrack)
            {
                TrackSnapData winningSnap     = null;
                float         winningDistance = Mathf.Infinity;

                foreach (TrackSnapData trackSnapData in connectedTrack.allTrackSnapData)
                {
                    Vector3 snapWorldPosition = trackSnapData.GetWorldPosition(connectedTrack);
                    float   sqrDist           = (snapWorldPosition - ownPosition).sqrMagnitude;
                    if (sqrDist < winningDistance)
                    {
                        winningDistance = sqrDist;
                        winningSnap     = trackSnapData;
                    }
                }

                if (winningSnap != null)
                {
                    float   connectedPositionAlong = connectedTrack.GetRegionPositionAlong(winningSnap.ID);
                    Vector3 worldPosition          = connectedTrack.GetGizmoPosition(connectedPositionAlong);
                    Handles.DrawDottedLine(ownPosition, worldPosition, 4f);
                }
            }
        }
Esempio n. 2
0
 /**
  * <summary>Gets the position in world space of the centre of the snap region</summary>
  * <param name="track">The track that the snap region is a part of.</param>
  * <returns>The snap region's position in world space</returns>
  **/
 public Vector3 GetWorldPosition(DragTrack track)
 {
     return(track.GetGizmoPosition(PositionAlong));
 }