I want to set a decreasing transparency level and I was thinking it might be more fun and more functional to do it with code ... (as the transparency levels could be tweaked without having to go back and forth between programs) What I'm curious about is setting the transparency levels of a texture map with code ... had a quick look through the manual but couldn't find a reference ... do you think it's possible .. or should I stick with importing multiple images with diminishing transparency?
Just set the color.a to equal a value in between 0 and 1. Make sure your using an alpha shader. http://unity3d.com/Documentation/ScriptReference/Color-a.html
I ended up using a few materials .. cause I was using a parallaxBump/AlphaDiffuse material and I didn't know how to apply the color.a to it ... here's the code ... Code (csharp): var m1 : Material; var m2 : Material; var m3 : Material; var m4 : Material; var m5 : Material; var c = 1; function Update () { transform.localScale.x += 0.05; transform.localScale.z += 0.05; c = (c + 1); if (c < 60) { renderer.sharedMaterial = m1; } if (c == 60) { renderer.sharedMaterial = m2; } if (c == 70) { renderer.sharedMaterial = m3; } if (c == 80) { renderer.sharedMaterial = m4; } if (c == 90) { renderer.sharedMaterial = m5; } if (c == 100) { Destroy(gameObject); } } It's a bit clunky though ... basically the materials have different opacities set to them starting at 5, 4, 3 ,2 ,1 Destroy!! ... I'll keep playing around with it ... see if I can get my head around the method you suggested ... cheers for now!
check jonathan's script here: http://forum.unity3d.com/viewtopic.php?t=1001 you could modify this to go to set values instead of fade completely if that's what you're looking for but this is the basic idea ; )
I'll definitely have a look at it tomorrow ... in the light of day ... it looks like it's the path to take ... thanks