Answer the question
In order to leave comments, you need to log in
How to draw lines of the desired color?
Hello!
Figured out how to draw lines on the playing field.
I do it like this:
private void DrawLine(Vector3 start, Vector3 stop, GameObject template)
{
GameObject toInstiateGridLine = template;
GameObject gridLineInstance = Instantiate(toInstiateGridLine, start, Quaternion.identity) as GameObject;
LineRenderer gridLineRenderer = gridLineInstance.GetComponent<LineRenderer>();
gridLineRenderer.SetVertexCount(2);
gridLineRenderer.SetWidth(0.01f, 0.01f);
gridLineRenderer.SetColors(Color.black, Color.black);
gridLineRenderer.SetPosition(0, start);
gridLineRenderer.SetPosition(1, stop);
}
Answer the question
In order to leave comments, you need to log in
The problem was that the LineRenderer didn't have a material.
I solved it with one line:
When accessing the material property, if it does not exist, a default material is created.
It is also possible to create the material yourself and attach it to the component (see SOF answer).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question