docs.unity3d.com
    Show / Hide Table of Contents

    Adjusting emissive intensity at runtime

    For High Definition Render Pipeline (HDRP) non-Shader Graph shaders, such as the Lit, Unlit, and Decal shaders, changing the _EmissiveIntensity property does not have any effect at runtime. This is because _EmissiveIntensity is not an independent property. The shader only uses _EmissiveIntensity to serialize the property in the UI and stores the final result in the _EmissiveColor property. To edit the intensity of emissive materials, set the _EmissiveColor and multiply it by the intensity you want.

    using UnityEngine;
    
    public class EditEmissiveIntensityExample : MonoBehaviour
    {
        public GameObject m_EmissiveObject;
    
        void Start()
        {
            float emissiveIntensity = 10;
            Color emissiveColor = Color.green;
            m_EmissiveObject.GetComponent<Renderer>().material.SetColor("_EmissiveColor", emissiveColor * emissiveIntensity);
        }
    }
    
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023