- Home /
Apply Render Texture To GUI + Transparency?
Hello,
I have made a texture render that I have applied to a camera in my scene. I was wondering if its possible to add this texture to a GUI window so I can get a little display window in my GUI, so I get a result like this (top left):
Answer by IJM · Nov 27, 2010 at 12:23 AM
I recomend using 32bit bitmaps with alpha channel. In general 24bit bitmpas (Something like Windows BMP or JPG) have Red,Gren and Blue (aka RGB) per each pixel, wich means that they can only suport opaque color. With 32bit you are getting 8 bits more per each pixel, and you can save transparency for it in range from 0.0 to 1.0. (0.0 is min, 0.5 is in the middle and 1.0 max) You can create such bitmpas easily with tools like GIMP or Photoshop. I recommand saving your bitmaps to TGA or PNG format. (Unity supports both)
p.s.
32bit bitmaps with alpha channel are also know as RGBA
p.p.s. U can use google.com for more on bitmaps ;)
But its not really a texture I'm applying, its a camera view using the Render Texture that I have applied to a camera within my scene ...
In Unity GUI works like a state machine, if you call GUI.color = new Color( 1,1,1, 0.5f); before GUI.DrawTexture that will set your alpha to 0.5f, you will need to call GUI.color = new Color( 1,1,1,1); after it to reset the alpha to 1.
Answer by oliver-jones · Nov 26, 2010 at 06:47 PM
Managed to get it to work. I used this in the GUI function:
GUI.DrawTexture(Rect(Screen.width - 300, Screen.height - 300,260,260), TurretCamera, ScaleMode.StretchToFill, false, 30.0f);
How would I apply a slight transparency to it?
You should be able to just put GUI.color = new Color( 1,1,1, 0.5f); in front of the DrawTexture.