Changing Emissive texture in C#

I’ve been trying to change an Emissive texture through C# and have gotten no results. I don’t know how to achieve this. I’ve tried


with no success. Changing emissive colors has been no problem for me, but I can’t seem to find anything anywhere on how to change the map itself. Any ideas?

You have to have the correct property name. In this instance, it would be:

     renderer.material.SetTexture ("_EmissionMap", myTexture);

However, keep in mind that you will probably have to also set the emission colour and power values yourself, as these are ‘black’ by default.

For anyone coming across this answer. The above did not work for me in 2021.3 HDRP. I had to use:

_gameObject.GetComponent<Renderer>().material.SetTexture("_EmissiveColorMap", _texture);

Also, it doesn’t seem that, at least in my unity version, that you’ll need to set color/intensity values anymore. At least not when changing the map. The values may default to black on a new allocation of the map, but when I changed mine, it simply retained the existing values.