A dashed line as trail

Hello,
I want to create a trail which is a dashed line with a specific length and faded out at the end. The object I would like to attach the trail to is only moving in straight lines. See the attached picture to get an idea of what I would like to do.

Do you guys have a idea how to do it?

I just made my own. Attach to whatever you want the effect on.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DashedTrailEffect : MonoBehaviour
{
    float timeBtwSpawns;
    public float startTimeBtwSpawns;
    public float deleteAfterSeconds;

    public GameObject dash;

    private void FixedUpdate()
    {
        if (timeBtwSpawns <= 0)
        {
            GameObject line = Instantiate(dash, transform.position, transform.rotation);
            Destroy(line, deleteAfterSeconds);
            timeBtwSpawns = startTimeBtwSpawns;
        }
        else
        {
            timeBtwSpawns -= Time.deltaTime;
        }
    }
}