- Home /
in game - how to partly invisible an object ?
hi there, i am new to unity so i am still learning .. ^^
my question, i can create a texture with e.g. black areas , assign this to an object and the black areas can went to transparent.
now i want to create this black / transparent areas in game, how can i do this ?
i would be nice if you could help me, thanks !!
Answer by erwin · Apr 11, 2012 at 12:07 PM
thanks for your replay the areas should be dynamic
i thougth, i have a texture, and draw on that ingame and assign that to the object with transparency information -but i dont know how :\
This should really be a comment to my answer, not a new answer. It keeps the place tidier :-)
If you want to create a texture dynamically, see http://answers.unity3d.com/questions/9919/how-do-i-create-a-texture-dynamically-in-unity.html
Answer by clfischer · Apr 11, 2012 at 10:53 AM
Maybe you could create an object with several materials: one for the transparent parts, another for the normal parts. Your object would then have renderer.materials[0] for the transparent parts and renderer.materials[1] for the rest. Set your transparent material to use one of the transparent shaders. You should be able to set renderer.materials[0].color.a (the alpha channel) to a value between 0 and 1 when you want to adjust the transparency. I think the texture used for your transparent material needs to have some transparency in it for this to work (an alpha channel in a PNG for instance).