I was finally able to get this to work after about an hour and a half of research.
Here is my code:
void Update () {
Renderer renderer = GetComponent<Renderer> ();
Material mat = renderer.material;
float emission = Mathf.PingPong (Time.time, 1.0f);
Color baseColor = Color.yellow; //Replace this with whatever you want for your base color at emission level '1'
Color finalColor = baseColor * Mathf.LinearToGammaSpace (emission);
mat.SetColor ("_EmissionColor", finalColor);
}
This should be all you need.
If you want to oscillate between something other than 0 and your ceiling (1.0 in this case) just declare emission as such:
If you want to slow down or speed up the oscillation, just multiply Time.time by a constant.
Multiplying Time.time by a constant greater than 1 will speed up the oscillation.
Multiplying Time.time by a constant less than 1 will slow down the oscillation.
Best of luck in your development! Make good things!
Or, you can select a material, right click, “select shader” and they will all be listed in your inspector. This DOES NOT WORK if you have Shaderforge installed, however. So St0Ff’s little script will come in handy for those who use it.
Incidentally, I am attempting to turn on emmissive on my materials, the following doesn’t work.
// turn on emission shader flag
material.EnableKeyword(“_EMISSION”);
// turn on realtime emissive GI
material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
material.SetColor(“_EmissionColor”, new Color(1.0f,1.0f,1.0f));
material.SetTexture(“_EmissionMap”), TryLoadTexture(texturePath));
,
// turn on emission shader flag
material.EnableKeyword(“_EMISSION”);
// turn on realtime emissive GI
material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
material.SetColor(“_EmissionColor”, new Color(1.0f,1.0f,1.0f));
material.SetTexture(“_EmissionMap”), TryLoadTexture(texturePath));