I’m trying to make transparent versions of a material (as a placement preview), but the code I’ve made doesn’t change the “Rendering Mode” in the editor or visually do anything aside from changing the color’s alpha.
Material mat;
void Start () {
mat = GetComponent<Renderer>().material;
}
void Update () {
if (Input.GetButtonDown("Fire1")) {//for testing/demonstration
print("Down "+mat.renderQueue);
mat.SetOverrideTag("RenderType", "Transparent");
mat.color = new Color(1, 0, 0, .5f);
mat.renderQueue = 3000;
}
}
The documentation on materials isn’t really helpful, but I’ve managed to link that transparent materials have the “RenderType” tag set to “Transparent”, and renderQueue at 3000. (I also noticed fully opaque objects don’t cast shadows, which I’d like to avoid.)
Is there an easy way to do this, or is it just setting a bunch of values? Does Unity “support” materials changing render methods, and is it just easier to copy essential values (albedo, normal, etc)to an already transparent material?