I know, that this question was asked before, but I could not find a proper answer to this. So how can I make my line dotted? I added a texture with a dot, but it just gets stretched for the length of the line, which is obviously not what I want. I'm using C# btw, if some code is needed here.
Edit: Inspector:
Edit: New Code :
public class dashedLine : MonoBehaviour
{
public Vector2 newPosition;
private LineRenderer line;
void Awake()
{
line = GetComponent<LineRenderer>();
}
void Update()
{
line.material.SetTextureOffset("_MainTex", new Vector2(Time.timeSinceLevelLoad * 4f, 0f));
line.material.SetTextureScale("_MainTex", new Vector2(newPosition.magnitude, 1f));
line.SetPosition(0, newPosition);
}
}
This is what I get:
Edit: This works now, when I use a Texture which has multiple dots in a row and put it to a material with Shader: Unlit/Transparent. I still don't know, why it's not working with a single dot.
Edit2: I had to recreate the dot texture with a single dot and it worked, so there was some issue on my side. Everything works now fine.