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
  4. Dismiss Notice

Issues with changing color on Sprite-Lit-Default material on Mesh Renderer

Discussion in '2D' started by ElnuDev, Jan 30, 2020.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Currently I have a Mesh Renderer using the
    Sprite-Lit-Default
    material. Unfortunately, the Mesh Renderer does not have a color parameter like the Sprite Renderer does, so I thought I'd try changing the color through script. I tried both
    someSpriteRenderer.material.color = someColor;
    and
    someSpriteRenderer.material.SetColor("_Color", someColor);
    but neither worked. However, both showed that a change had been when then debugging
    someSpriteRenderer.material.color
    or
    someSpriteRenderer.material.GetColor("_Color")
    , although there was no visual change in color in the scene. The only lead I've found in terms of finding a solution is the fact that changing the color works when the material is
    Sprites-Default
    , but not when it is
    Sprite-Lit-Default
    . Any thoughts on fixing this? I've currently have my project set up with Unity 2019.3.0f6 and Universal RP 7.1.8. Thanks in advance!
     
    erdostamasa, tbriz and boogi505 like this.
  2. boogi505

    boogi505

    Joined:
    May 21, 2019
    Posts:
    3
    i have same problem
     
    erdostamasa and tbriz like this.
  3. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I fixed it by making a custom shader graph that is essentially a
    Sprite-Lit-Default
    clone. Hopefully they fix this soon!
     
  4. Lortimus14

    Lortimus14

    Joined:
    Jan 12, 2017
    Posts:
    7
    Same problem for me. Do we know if this is being worked on?
     
    tbriz and ElnuDev like this.
  5. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Frankly, I doubt it. It's a pretty niche problem, but for now I guess one will just have to make a custom shader
     
    tbriz likes this.
  6. csondika

    csondika

    Joined:
    Jul 14, 2018
    Posts:
    2
    Same for me with Unity 2019.3.3f1. I'm glad I found this post, so I can spend time on the workaround instead.
     
    tbriz likes this.
  7. HazelTrinity

    HazelTrinity

    Joined:
    Feb 28, 2020
    Posts:
    3
    Any chance you could post the shader you wrote? I'd like to save myself that effort if possible. Thanks.
     
    tbriz likes this.
  8. Infinite-3D

    Infinite-3D

    Joined:
    Jan 5, 2020
    Posts:
    37
    \
    can you please post that shader? I'm completely lost
     
    tbriz likes this.
  9. triangle4studios

    triangle4studios

    Joined:
    Jun 28, 2020
    Posts:
    32
    Yeah not sure what the point is to telling the world you fixed it by creating a shader and then not sharing it. Thats kind of rude.
     
  10. ChillinTech

    ChillinTech

    Joined:
    Aug 12, 2018
    Posts:
    5
    so probably not the greatest way, but definitely the laziest:
    1) find the Sprite-Lit-Default shader (recommended to make a copy of it)
    2) open in editor and delete the HideInInspector attribute for RendererColor
    3) go on to live a colorful life
    upload_2021-9-14_10-9-51.png
    or if you just want to do it in code, the parameter name is
    RendererColor
     
    erdostamasa likes this.
  11. TalkingBlah

    TalkingBlah

    Joined:
    Jun 10, 2020
    Posts:
    2
    Hi I am pretty new to Unity and this is my first day ever working with shaders. I think I might have fixed this issue and am sharing it here for anyone who runs into this issue. If the problem was not fixed I apologize because it's been barely hours since i looked into what shaders are. the Unity version I am using is 2020.1.10f1 and it worked for me in that version with URP 10.5.1. Also Make sure what you want to change is material color not Sprite color because sprite color can be changed by calling SpriteRenderer.colorMethod.
     

    Attached Files:

    KHodow and erdostamasa like this.