Search Unity

Question Different Shaders

Discussion in 'Shader Graph' started by Talmagett, Dec 6, 2020.

  1. Talmagett

    Talmagett

    Joined:
    May 26, 2019
    Posts:
    3
    Hello. I make a dissolve shader and put it on enemy prefab. When he dies it dissolves. Buut when one die all enemies in scene dissolve. Can i make unique materials on each enemy with script,on start maybe? (I'm working with 2D)
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi and welcome,

    You need to have an unique instance of the material. How are you changing the material, can you share that part of the code?
     
  3. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Here's a few lines of code, I think this should do the trick.

    Code (CSharp):
    1. Renderer m_renderer = GetComponent<Renderer>();
    2. m_renderer.material.SetFloat("_aFloatValue", 1.0f);
    3. m_renderer.material.SetColor("_Color", Color.blue);
     
    Talmagett likes this.
  4. Talmagett

    Talmagett

    Joined:
    May 26, 2019
    Posts:
    3