- Home /
How do I make a grey cube transparent?
var colorStart : Color = Color.red;//Changed to grey var colorEnd : Color = Color.green;//Changed to transparent grey var duration : float = 1.0; var lerp : float = 0.5;
function Update () { var lerp : float = Mathf.PingPong (Time.time, duration) / duration; renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp);
renderer.material.color = new Color(0, 0, 0, 50);
renderer.material.color.a = 0.5;
var c : Color = renderer.material.color;
c.a = 0.5f;
renderer.material.color = c;
}
How do I make an object transparent? It currently is not equipped with any textures at all, and I'm just trying to make the thing transparent to mark for the players that "Hoy! There is something in this zone, so get over here!" A grey transparent cube marking a zone. How would I do this?
BTW, none of the things written above work. Either because I have no idea why, or some other reason. Care to point me out why?
Answer by Jean-Fabre · May 04, 2011 at 05:21 AM
Hi,
If your shader doesn't support transparency, you won't have any. So on that material applied to your gameObject you want to change transparency, make sure you select a shader that deals with alpha channel.
When you select a material, there is a "shader" property. It will let you select amongst a wide varieties, and pick one from the transparent category like "Transparent/Diffuse". Then depending on your need/performances, you'll need to pick a more appropriate one.
You'll find all built in shaders described here
Bye,
Jean
Thanks @$$anonymous$$ Fabre . Your answer saved my day. :) Cheers!
You want to look for the rendering mode. You can pause your scene and select your game object in the scene tree / outliner. Look at Default $$anonymous$$aterial Standard Shader (expand section if necessary) and select rendering mode Transparent. Also check if your Albedo color actually has a alpha below 255 (or 1).
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Distribute terrain in zones 3 Answers
Unity 5 upside down texture on 1 side of cube 1 Answer
using rgb to change color c# 1 Answer