- Home /
Render GUI with Material
Hi,
Does anyone know how to render a 2D Texture with an attached element? I can't use Graphics.DrawTexture, because this is only available in the pro version.
GUI.DrawTexture, cant use any material. The reason i want to do this, is that i want to change the color of an image in code. I can do this with the material and a Transparent/Cutoff/Diffuse shader on it.
Thanks
Answer by Mike 3 · Nov 24, 2010 at 10:43 PM
You could just use GUI.color to change the colour of the texture:
GUI.color = Color.red; //tint the texture red
GUI.DrawTexture(rect, tex);
GUI.color = Color.white; //set it back to normal so it doesn't screw the rest of the GUI
Alternatively you could use a GUITexture, which will let you set the material
Hi,
Thank you for you comment. Unfortunaly i only want to color the inside of my texture. So for example, the inside of a box.
Setting the GUI color doesnt work at all, even if i wanted to color all of my texture.
I will have a look at the GUITexture thingie. Can you use shaders with that?
Yeah, you can use any shader you like with them. Regarding GUI.color though - are you sure it doesn't do what you want it to do? I use it to tint single textures, exactly like changing the colour on a material
Take an arrow for example. I need to color the inside of the arrow (which is transparent), with an color to my choice. I can do this with an Transparent/Cutout/Diffuse shader, but if i use the GUI.Color nothing happens.
I will have a look at the GUITexture now.
Your arrow example works well with GUI.color at my end - the arrow itself is tinted, the alpha area around it isn't
Could you send me your arrow $$anonymous$$ike? I cannot get it to work with GUI.Color.
I've still got the Graphics.DrawTexture now.
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Menu material error 1 Answer
How to check if Mouse is touching GUI Texture 1 Answer