Example #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);
    }
 void Update()
 {
     if (trackSection.Next == null)
     {
         Highlighter.DrawHighlighter(Matrix4x4.TRS(trackSection.EndPosition + Vector3.up, trackSection.EndRotation, Vector3.one));
     }
     if (trackSection.Previous == null)
     {
         Highlighter.DrawHighlighter(Matrix4x4.TRS(trackSection.Position + Vector3.up, trackSection.Rotation, Vector3.one));
     }
 }
Example #3
0
    public override void OnTrackHover(TrackSectionComponent track, ActivateInfo info)
    {
        if (selectedWagon != null)
        {
            float distance;
            // TODO: Draw ghost instead
            var matrix = Matrix4x4.TRS(GetSnappedTrackPosition(track.trackSection, info.hit.point, out distance),
                                       track.trackSection.GetRotationOnTrack(distance),
                                       Vector3.one);

            Highlighter.DrawHighlighter(matrix);

            Graphics.DrawMesh(selectedWagon.GetComponent <MeshFilter>().sharedMesh, matrix, selectedWagon.GetComponent <MeshRenderer>().sharedMaterial, gameObject.layer);
        }
    }