Changing Material Emission Level via Script?

Hello. I am currently writing a script in which the emission level of an object’s material will be dictated by a public variable that may be edited in the inspector via slider, once the player activates a trigger. However, I’m unable to correctly reference the emission level itself. The following is some code that I wrote up:

 void OnTriggerEnter(Collider other)
    {
        if (other == Player)
        {
            targetObject.GetComponent<Material>().Emission = emissionIntensity;
            source.PlayOneShot(activationSound, soundVolume);
        }
    }

Obviously, “.Emission” is not the correct reference to the emission level of a material. What would I replace this with so that this script works as it should?

FYI if you select a material in the project and click on the little cog top right in the inspector and choose “edit shader” it’ll list all the property names in the inspector

Assuming you’re using the standard shader I guess you’ll need “_EmissionColor”

Thank you for your reply,

I followed your advice, and my new code is as follows:

 void OnTriggerEnter(Collider other)
    {
        if (other == Player)
        {
            targetObject.GetComponent<Material>().shader._EmissionColor = emissionIntensity;
            source.PlayOneShot(activationSound, soundVolume);
        }
    }

The only issue that still remains is that “_EmissionColor” is not recognized as a child of “shader”. I tried many other properties of shaders, such as just “_Color”, and still it fails to work? Is “_EmissionColor” correct and I’m just missing something else?