In Unity 5, I have a material called “PlayerMaterial” and I’ve tried both the Standard and the Standard Specular to CHANGE the Emission level at run-time in C#.
You see, I can change it in the Inspector - BUT - during game play events occur where I want to INCREASE or DECREASE the Emission level (making the player appear brighter or dimmer) …
I’ve read over the DynamicGI and tried some things there but none have any effect on the Emission level.
See the screenshot of the Inspector - the yellow highlight is what I want to change at run-time in my C# code.
Hi I cannot get my head around this. There seems to be no direct way of controlling the ‘multiplier’ (yellow highlighted box in original post). My problem is that I am using a (cut and paste) script to up and down (animated pulse) the emission value during game play, this leaves the ‘multiplier’ at a random value when the game is stopped - which then needs resetting in the inspector. Is there a way to directly or indirectly reset the ‘multiplier’ value through the script? Here’s what I currently have as a script,
public class emissiveGlow : MonoBehaviour {
public float frequency = 1f;
public float amplitude = 1f;
public Material material;
public Color startEmissionColor = new Color(0.1F, 0.1F, 1.0F, 1F);
public Color newEmissionColor;
Renderer myRenderer;
// Use this for initialization
void Start()
{
myRenderer = GetComponent<Renderer>();
newEmissionColor = startEmissionColor;
}
// Update is called once per frame
void Update()
{
float glow = (2 + Mathf.Cos(Time.time * frequency)) * amplitude;
material.SetColor("_EmissionColor", newEmissionColor * glow);
DynamicGI.UpdateMaterials(myRenderer);
}
}
I don’t understand all the replies on this thread lol.
You can’t use math with a Color type?
Agrument2 cannot convert from mUnityEngine.Color to float.