- Home /
How to make this image semi-transparent?
This is suppose to be a "hurt" image, in that when your health falls at like 3 hearts or something, this will automatically appear. The problem that I have is that I have no clue on how to make this semi-transparent. I looked up a lot of places, and it said something about color.a and alpha and all that stuff. Is that what "Opacity" is? Also, how can I can stretch that image to screen width and height? I want to change the image's properties via script. I find some things that are very annoying on Unity that they can't just make a simple "Opacity: <1-100>" property.
Answer by kristercollin · Sep 24, 2012 at 07:44 AM
AngryCSharpNerd,
There are several ways of doing this, but the one I would most likely use (from what you've described) is to create a GUI Texture object that holds the image.
So, I'd start by creating the image using (Gimp/Photoshop/Paint/etc...) without any transparency, then bring it in as an asset in Unity. Select it, then go to the "GameObject" menu, select a GUI Texture (which will automatically create it with the right resolution, etc...) then you go to the inspector, select the Color segment and then change the Alpha value to what you'd like. Then, once that's done you can use a script to tell the image to appear and, because it's a GUI Texture, it will be viewed on top of everything else as desired.
To make it prettier, though, you can use a script to manually change the alpha value so that when the image is needed you can fade into it being there and increase/decrease it's opacity to reflect intensity.
Answer by Eric5h5 · Sep 24, 2012 at 06:36 AM
Use a full-screen GUITexture (not OnGUI code) and set the alpha appropriately.
I find some things that are very annoying on Unity that they can't just make a simple "Opacity: <1-100>" property.
Well, except you can, for just about everything. But alpha is not 0-100, it's 0.0-1.0.
Answer by m5k · Sep 23, 2012 at 03:24 PM
Try using Photoshop or another solution to create a semi transparent png or create a dds with a grey alpha layer.
Would you know how to do that for Paint.NET? I'm quite new at it and I'd need a tutorial.
Your answer
Follow this Question
Related Questions
transparent mode does not work at alpha=255 1 Answer
Object opacity/alpha? 1 Answer
Need help with opacity error 0 Answers
GUI.DrawTexture - Slightly Transparent? 1 Answer
Panel Opacity 1 Answer