Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Standard Shader EnableKeyword("_EMISSION") Not Working on Mobile

Discussion in 'Shaders' started by wkwan, Dec 21, 2015.

  1. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
    I've got a cube using a material with the standard shader, and I want to vary the Emission dynamically.

    I'm doing it like this:
    newMesh.material.EnableKeyword("_EMISSION");
    newMesh.material.SetColor("_EmissionColor", emissionBlue);

    and it works fine in the editor. However, it doesn't do anything when I build for iOS and Android (even when I set the quality settings to Fantastic). Furthermore, it used to work before I upgraded to 5.3.1f1.

    Here's how my material looks:
    Screen Shot 2015-12-21 at 5.41.24 PM.png
     
  2. wkwan

    wkwan

    Joined:
    Sep 14, 2014
    Posts:
    27
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The ShaderVariantCollection is the official way to get unity to not to stip shader variants that are used only at runtime but not included into the scene.
     
  4. Voliware

    Voliware

    Joined:
    Feb 4, 2023
    Posts:
    3
    You probably also need to do this

    renderer.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;