- Home /
How to set LineRenderer color?
I add line renderer to my game object. I use following code to set the color.
void Start ()
{
spiderWeb = gameObject.GetComponent<LineRenderer>();
spiderWeb.material = new Material ( Shader.Find("Diffuse"));
spiderWeb.material.SetColor("_Color",new Color(0.9333f,0.26275f,0.5938f));
spiderWeb.castShadows = false;
spiderWeb.receiveShadows = false;
spiderWeb.SetWidth(3, 3);
spiderWeb.SetColors(new Color(0.9333f,0.26275f,0.5938f), new Color(0.9333f,0.26275f,0.5938f));
spiderWeb.SetVertexCount(2);
spiderWeb.SetPosition(0,spiderStartPos);
spiderWeb.SetPosition(1,spiderStartPos);
spiderWeb.enabled = true;
}
But the color I am getting is gray, it should be pink. Any idea what I did wrong?
Did you check the shader? If its a diffuse shader it will have a gray-ish tint to the color.
Also, you are setting the width to 3,3. That's a bit small, isn't it? $$anonymous$$aybe you are just looking at the skybox/background. Try making it bigger so you can see it?
3,3 width is O$$anonymous$$. I can see it.
You maybe right about the shader. But I am not sure what I should be using ..
If the color is pink with a gray-ish tint, that's b/c its using the diffuse shader. If you have unity pro, try using sprite/vertex colored, fast.
If you don't have unity pro, you would have to write you own or look for a shader that displays "normal"/"true"(for lack of a better term) colors.
Your answer
Follow this Question
Related Questions
LineRenderer not showing the correct color. 1 Answer
LineRenderer renders the wrong color 3 Answers
How do I make this paint shader effect where I create random holes over something I paint over? 1 Answer
LineRenderer not showing the correct color 0 Answers
Line Renderer Appears Semi-Transparent instead of White? 1 Answer