Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Standard Shader - Can't change emission color in runtime

Discussion in 'Unity 5 Pre-order Beta' started by glitchedTime, Jan 15, 2015.

  1. glitchedTime

    glitchedTime

    Joined:
    Jun 5, 2013
    Posts:
    15
    Hello, is there a way to change Emission Color during runtime? The problem is that if you start the game by having Emission Color as Black, it seems that Unity discards the Emission part because it's not used, so even if you change it by using material.SetColor("_EmissionColor", color) it does nothing, simply because that part of shader seems to be deactivated for performance reasons I guess. Is there a way to 'reactivate' that part of shader during runtime?
    I know that I can just go through all materials and set their emissive color to 1, 1, 1 (RGB), but it's a pain to do so.
     
    quangtqag and CometGoat like this.
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    material.EnableKeyword ("_EMISSION"); should work.
     
  3. glitchedTime

    glitchedTime

    Joined:
    Jun 5, 2013
    Posts:
    15
    Thank you!
     
  4. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Uh, this is a hidden feature, how may users know this?
    Is there any official docs on enabling keywords?
     
  5. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Yes, its in the docs, just click on the help button in your material inspector.