x


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

more ▼

asked Nov 24 '10 at 10:16 PM

Maarten gravatar image

Maarten
607 2 4 12

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Nov 24 '10 at 10:43 PM

Mike 3 gravatar image

Mike 3
30.5k 10 65 252

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?

Nov 24 '10 at 10:58 PM Maarten

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

Nov 25 '10 at 12:38 AM Mike 3

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.

Nov 25 '10 at 09:41 AM Maarten

Your arrow example works well with GUI.color at my end - the arrow itself is tinted, the alpha area around it isn't

Nov 25 '10 at 02:26 PM Mike 3

Could you send me your arrow Mike? I cannot get it to work with GUI.Color.

I've still got the Graphics.DrawTexture now.

Nov 30 '10 at 08:17 AM Maarten
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5061
x3674
x2193
x809

asked: Nov 24 '10 at 10:16 PM

Seen: 2577 times

Last Updated: Nov 24 '10 at 10:16 PM