Ejemplo n.º 1
0
        private void DrawTrackRegions(TrackSnapData trackSnapData, DragTrack_Curved curvedTrack)
        {
            float minPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong - trackSnapData.Width);
            float maxPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong + trackSnapData.Width);

            Quaternion rot   = Quaternion.AngleAxis(curvedTrack.MaxAngle * trackSnapData.PositionAlong, curvedTrack.transform.forward);
            Vector3    endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, rot);

            Handles.color = trackSnapData.GizmoColor;
            Vector3 positionAlongWorld = curvedTrack.GetGizmoPosition(trackSnapData.PositionAlong);

            Handles.DrawSolidDisc(positionAlongWorld, endUp, curvedTrack.discSize / 2f);

            rot   = Quaternion.AngleAxis(curvedTrack.MaxAngle * minPositionAlong, curvedTrack.transform.forward);
            endUp = RotatePointAroundPivot(curvedTrack.transform.right, Vector3.zero, rot);

            Handles.DrawWireArc(curvedTrack.transform.position, curvedTrack.transform.forward, endUp, curvedTrack.MaxAngle * (maxPositionAlong - minPositionAlong), curvedTrack.radius * 1.01f);

            Quaternion minRot = Quaternion.AngleAxis(curvedTrack.MaxAngle * minPositionAlong, curvedTrack.transform.forward);

            endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, minRot);
            Vector3 minPositionAlongWorld = curvedTrack.GetGizmoPosition(minPositionAlong);

            Handles.DrawSolidDisc(minPositionAlongWorld, endUp, curvedTrack.discSize / 4f);

            Quaternion maxRot = Quaternion.AngleAxis(curvedTrack.MaxAngle * maxPositionAlong, curvedTrack.transform.forward);

            endUp = RotatePointAroundPivot(curvedTrack.transform.up, Vector3.zero, maxRot);
            Vector3 maxPositionAlongWorld = curvedTrack.GetGizmoPosition(maxPositionAlong);

            Handles.DrawSolidDisc(maxPositionAlongWorld, endUp, curvedTrack.discSize / 4f);

            trackSnapData.DrawConnectionHandles(curvedTrack);
        }
Ejemplo n.º 2
0
        private void DrawTrackRegions(TrackSnapData trackSnapData, DragTrack_Straight straightTrack)
        {
            float minPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong - trackSnapData.Width);
            float maxPositionAlong = Mathf.Clamp01(trackSnapData.PositionAlong + trackSnapData.Width);

            Handles.color = trackSnapData.GizmoColor;

            Handles.DrawSolidDisc(straightTrack.GetGizmoPosition(trackSnapData.PositionAlong), straightTrack.transform.up, straightTrack.discSize / 2f);
            Handles.DrawSolidDisc(straightTrack.GetGizmoPosition(minPositionAlong), straightTrack.transform.up, straightTrack.discSize / 4f);
            Handles.DrawSolidDisc(straightTrack.GetGizmoPosition(maxPositionAlong), straightTrack.transform.up, straightTrack.discSize / 4f);
            Handles.DrawLine(straightTrack.GetGizmoPosition(minPositionAlong), straightTrack.GetGizmoPosition(maxPositionAlong));

            trackSnapData.DrawConnectionHandles(straightTrack);
        }