Hello!
I made an application with trees, created by Unity Tree Creator. I want filter some trees, so I replace shader and color to make transparent trees. It works in debug and standalone version too. Here’s the code:
private void SetTransparent(GameObject g)
{
for (int i = 0; i < g.renderer.materials.Length; i++)
{
g.renderer.materials*.shader = Shader.Find("Transparent/Diffuse");*
g.renderer.materials*.SetColor("Color", new Color(1, 1, 1, 0.1f));
_}*
for (int i = 0; i < g.transform.childCount; i++)
SetTransparent(g.transform.GetChild(i).gameObject);
}
And the result:
[25749-transp.jpg|25749]_
I have an invert method to restore original shader and material color:
private void RevertTransparent(GameObject g)
_{_
for (int i = 0; i < g.renderer.materials.Length; i++)
_{_
_if (g.renderer.materials.name == “Optimized Bark Material (Instance)”)_
_g.renderer.materials.shader =
Shader.Find(“Nature/Tree Creator Bark”);_
_else if (g.renderer.materials.name ==
“Optimized Leaf Material (Instance)”)_
_g.renderer.materials.shader =
Shader.Find(“Nature/Tree Creator Leaves Fast”);
else_
_g.renderer.materials.shader = Shader.Find(“Default/Diffuse”);_
g.renderer.materials.SetColor("Color", new Color(1,1,1));*
}
for (int i = 0; i < g.transform.childCount; i++)
SetTransparent(g.transform.GetChild(i).gameObject);
}
And the restoring works only in debug mode in unity editor, in builded version this happens:
[25750-revtransp.jpg|25750]*
Any idea how to properly change textures in standalone version too?
*
*