x


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):

alt text

more ▼

asked Nov 26 '10 at 06:20 PM

oliver-jones gravatar image

oliver-jones
2.5k 205 225 254

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

2 answers: sort voted first

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 http://google.com for more on bitmaps ;)

more ▼

answered Nov 27 '10 at 12:23 AM

IJM gravatar image

IJM
1.4k 2 5 19

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 ...

Nov 27 '10 at 12:29 AM oliver-jones

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.

Nov 27 '10 at 11:07 AM IJM
(comments are locked)
10|3000 characters needed characters left

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?

more ▼

answered Nov 26 '10 at 06:47 PM

oliver-jones gravatar image

oliver-jones
2.5k 205 225 254

You should be able to just put GUI.color = new Color( 1,1,1, 0.5f); in front of the DrawTexture.

Nov 27 '10 at 02:47 AM Molix
(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:

x3689
x3006
x2203
x266
x19

asked: Nov 26 '10 at 06:20 PM

Seen: 5375 times

Last Updated: Nov 27 '10 at 12:31 AM