1
votes

I have created lines using this,

LineRenderer line = new GameObject ("Line " + i.ToString ()).AddComponent<LineRenderer>();
line.SetColors (transRed, transRed);
Material lineGreen = new Material(Shader.Find("Particles/Alpha Blended"));
line.material = lineGreen;

and a sphere like this,

GameObject mySphere = GameObject.CreatePrimitive(PrimitiveType.Sphere) as GameObject;
Material myMaterial = new Material(Shader.Find("Particles/Alpha Blended"));
myMaterial.color = transRed;
mySphere.GetComponent<MeshRenderer> ().material = myMaterial;

The colour transRed is,

transRed.a = 0.4f;
transRed.r = 1.1f;
transRed.g = 0.496078431f;
transRed.b = 0.0f;

My problem is that the line and sphere aren't coming in same colour. The line is of the colour I want, but the sphere is white. I'm using same shader and same colour variable. Any help?

1

1 Answers

0
votes

I believe "Particles/Alpha Blended" does not care about .color setting. set color via shader's property like this:

    myMaterial.SetColor("_Color", transRed);

have a look at unity's documentation here