- Home /
InternalErrorShader
When I test my game I get a Non-working shader that doesn't serve the intended function which is to change the Emission Color of my troll from black to white. I want to modify the script to change the color over time eventually. Does anyone know why I'm getting this error, or how to write a better C# script that will change the emission color of my troll?
Can you post the error you get and the code? (Preferably with the code tags) That way we can test your code way faster.
Its in the picture above. I start with just my "overlay" shader, but when I run the game a new shader "overlay (Inheritance)" appears with the dropdown that reads "Hidden/InternalErrorShader" and makes my troll look like a pink mass.
I'm trying to program the emission to change from the dark one to the white one, in the picture below, in game. $$anonymous$$y goal is to make it change from black to white based on its health, but in this script I'm just trying to change the emission at the start, because, frankly, I'm not sure how to write a proper script that can change an objects emission.
alt text http://answers.unity3d.com/storage/temp/59153-screen-shot-2015-12-01-at-22539-pm.png alt text screen-shot-2015-12-01-at-22539-pm.png (50.9 kB) screen-shot-2015-12-01-at-22523-pm.png (32.2 kB)
is "overlay" the material name or the shader name? Looks like a material named overlay using a Standard shader.
What happens if you remove the line:
troll.material.shader = Shader.Find("overlay");
If I remove the line, the troll stays its normal dark presence without switching to white. I also tried replacing "overlay" with "Emission" and "EmissionColor." Both of those produce the result as before where the troll turns pink and the Emission Color doesn't change.
Answer by Jessespike · Dec 02, 2015 at 10:59 PM
I think there's some confusion with your names and strings. Replacing "overlay" with "Emission" won't work. I think overlay is your material name, but you're trying to use it as a shader name. And using Properties as a shader name won't work. Here's a simple test that worked for me:
Material mat = GetComponent<Renderer>().material;
Color newColor = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f));
mat.SetColor("_EmissionColor", newColor);