Z
Z
Zefirot2021-09-01 11:21:18
Unity
Zefirot, 2021-09-01 11:21:18

How to create multiple lines from the same object with different colors?

To make it clearer what I mean, I will give an example of all kinds of research in games, from one research there are branches according to the type of what needs to be researched in order to open this or that research, so it turns out that those studies that are already open to them, for example, should have a red line, and those that are closed by a black line, I draw the lines themselves like this.

public LineRenderer lr;
....
lr.positionCount = 6;
lr.SetPosition(0, Position0);
lr.SetPosition(1, Position1);
lr.SetPosition(2, Position0);
lr.SetPosition(3, Position2);
lr.SetPosition(4, Position0);
lr.SetPosition(5, Position3);
lr.GetComponent<Renderer>().sharedMaterial.color = new Color(0f, 0f, 1f, 1f);
lr.startWidth = 0.075f;
lr.endWidth = 0.075f;

in this case, the color is set to all lines at once, but how about each individual one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JeremiSharkboy, 2021-09-01
@Zefirot

1 line - 1 color
If you want two colors, draw two lines

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question