Instantiate a prefab every certain distance while swipping (iOS)

I'm touching the touch screen and a prefab is instantiated where I have placed my finger.

Now, keeping my finger on the screen, I begin to swipe.

A prefab's clone is instantiated every say 10 pixels.

The result would be something like a dotted line along the swipe path.

How do I do this?

I’d do this by testing the touch position against the position of the last prefab and if it meets the threshhold - then create a new prefab.

Here is some untested C# code (my syntax checking isn’t nearly as good as a compilers):

//last position where we drew the dot
Vector2 lastDotPos;
public float dotDropDist = 10; //min distance between dots
	
void Update () {
	foreach (Touch touch in Input.touches) {
		//if we start touching
		if (touch.phase == TouchPhase.Began) {
			Instantiate(prefabDot, new Vector3(touch.x, touch.y, 0, Quaternion.identity)
			lastDotPos = touch.position;
			break; //ignore the rest of the touches if any
		} else if (touch.phase == TouchPhase.Move) {
			//get the total pixels moved
			float distance = Mathf.Abs(touch.position.y - lastDotPos.y) + Mathf.Abs(touch.position.y - lastDotPos.y)
			//if we meet the threshold the create a new dot and reset our last dot position.
			if (distance > dotDropDist) {
				Instantiate(prefabDot, new Vector3(touch.x, touch.y, 0, Quaternion.identity)
				lastDotPos = touch.position;
			}
			break; //ignore the rest of the touches if any
		}
	}
}