예제 #1
0
    protected bool HighlightClosestEnd(TrackSection trackSection, bool onlyUnconnected, Vector3 point, out bool startIsClosest)
    {
        var toEnd   = Vector3.Distance(point, trackSection.EndPosition);
        var toStart = Vector3.Distance(point, trackSection.Position);

        startIsClosest = false;

        if (toEnd < toStart)
        {
            if (trackSection.Next == null || !onlyUnconnected)
            {
                Highlighter.DrawHighlighter(Matrix4x4.TRS(trackSection.EndPosition, trackSection.GetRotationOnTrack(trackSection.Length), Vector3.one));
                return(true);
            }
        }
        else
        {
            if (trackSection.Previous == null || !onlyUnconnected)
            {
                Highlighter.DrawHighlighter(Matrix4x4.TRS(trackSection.Position, trackSection.Rotation, Vector3.one));
                startIsClosest = true;
                return(true);
            }
        }
        return(false);
    }