ds223
1
I am trying to tint an image, here is my code:
public Texture2D image;
GetComponent<MeshRenderer>().material.shader = Shader.Find("Unlit/Texture");
GetComponent<MeshRenderer>().material.mainTexture = image;
GetComponent<Renderer>().material.color = new Color(1, 0, 0, 0);
If I just have this code it does tint the image but it is dark:
GetComponent<MeshRenderer>().material.mainTexture = image;
GetComponent<Renderer>().material.color = new Color(1, 0, 0, 0);
Thanks
why are you setting the alpha to zero? it mean transparent
ds223
3
Was trying anything, setting it to this does the same thing:
Color(1, 0, 0);
and if you do Color(1f, 0f, 0f, 1f);
this should be solid red, does it do something in the inspector?
any thing showing up in the console?
ds223
5
Hopefully this shows the problem better:
See attached images
with shader.png is running this:
GetComponent<MeshRenderer>().material.shader = Shader.Find("Unlit/Texture");
GetComponent<MeshRenderer>().material.mainTexture = image;
GetComponent<Renderer>().material.color = new Color(1f, 0f, 0f, 1f);
without shader.png is running this:
GetComponent<MeshRenderer>().material.mainTexture = image;
GetComponent<Renderer>().material.color = new Color(1f, 0f, 0f, 1f);
without shader and no red.png is running this:
GetComponent<MeshRenderer>().material.mainTexture = image;
Notice how “without shader and no red.png” is darker than “with shader.png”