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

How can I change the emission value during runtime using C#?

Discussion in 'Scripting' started by Lunastras, Jun 30, 2017.

  1. Lunastras

    Lunastras

    Joined:
    Jun 28, 2017
    Posts:
    6
    I want to make my character flash a bit green when he gets some health, but I do not want to change his entire texture, just make it more green. I tried looking on the forums for some solutions, but a good chunck of them were outdated.
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    2D or 3D character? What kind of materials are you using for your character?

    If you can just modify the material color, that might be the way to go.
     
    idurvesh likes this.
  3. Lunastras

    Lunastras

    Joined:
    Jun 28, 2017
    Posts:
    6

    It is a 3D project, but the characters are planes. I am using the stanard shader for them and a texture. Isn't changing the material colour going to make the entire plane green?

    UPDATE

    Thanks! I can make the texture a bit green without making the entire material a solid colour. Although, I have another thing I want to change emission for. I want the enemies to flash white when they are hit, and changing the colour to white only seems to give the original material, so making them white only seems to be achieveable with emission change to white. Is there any other way of doing it?
     
    Last edited: Jul 1, 2017
    idurvesh likes this.
  4. idurvesh

    idurvesh

    Joined:
    Jun 9, 2014
    Posts:
    495
    That's right use emission or you can swap the materials...
     
  5. Lunastras

    Lunastras

    Joined:
    Jun 28, 2017
    Posts:
    6
    Yes, but that was my initial question, how do I manipulate emission?