LWRP not updating material correctly

This is extremely annoying, have to switch to hdrp because the material isn’t really updating in lwrp, or particle effects. I activate for example emission and choose white and nothing happens. I have to click on play and exit and click on another material in order to see the change. Same goes with particle effects. Tried on two different new projects …

I have unity 2019.2.13f1
lwrp 6.9.2 and 6.9.0

I’m having the same issue with URP on 2019.3. I set the emission color, but it isn’t updating until I select the object and expand the material.

Edit: Got it working like this:

mat.SetColor("_EmissionColor", targetColor);
mat.EnableKeyword("_EMISSION");

Src: Unity - Manual: Using materials with C# scripts

1 Like

Hi could you submit a bug for this?

We have found the issue and fixed it in our master branch, back porting to the 19.3 release branch and will be going out in our next package, hopefully it will land in the 7.1.7 Universal RP package otherwise it will land early next year in the 7.2.0 package.

1 Like

I am having an issue the same as this? Anyone know if this has been pushed? Thank you!

Unfortunately it did indeed miss the 7.1.7 package, but has been back-ported to a 7.1.8 package that should be releasing next week. Here is the Github PR

This is still happening on 7.3.1 (unity 2019.3.7f1)

Yes, you’re right. I just did a quick check and I see that this is still an issue for Particle Lit, Particle SimpleLit and Particle Unlit shaders. Thanks for letting us know.

I’ve made a PR to fix this and it should be in the next release.

I’m having the same issue as the original poster - Unity 2019.4.0f1, URP 7.3.1 - any word on this?

Have this bug been corrected in recent URP version ?

I can’t seem to update the my sprite’s material at runtime.

myRenderer.material.color = myColor;
myRenderer.material.SetColor("_Color", myColor);
myRenderer.material.SetColor("_BaseColor", myColor);
myRenderer.material.SetColor("_EmissionColor", myColor);

myRenderer.material.EnableKeyword("_EMISSION");

None of the above work.

There was a suggestion in another thread to change from:

myRenderer.material

to:

myRenderer.materials[0]

I tried this with all above iterations and this also does not work.

I’m still having this issue in 2019.4.16f1. Was this perhaps fixed in one of the later updates?

@phil_lira Sorry to necro a old Thread but I’m having the same issue on Unity 2021.2.10f URP 12.1.4 I’m changing a material prop block from a custom timeline playable. Here is the code I use :

  public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (_meshRenderer != null)
        {
            Color color = matPropBlock.GetColor(_EmissionID);
            time += info.deltaTime;
            color = Color.LerpUnclamped(color, _emissionColor, (float)(time /playable.GetDuration()));
            matPropBlock.SetColor(_EmissionID, color);
            _meshRenderer.SetPropertyBlock(matPropBlock);
            _meshRenderer.sharedMaterial.EnableKeyword("_EMISSION");
        }
    }

The enable keyword “hack” is the only thing that got the material to update.

3 Likes

Having the same issue in Unity 2021.2.17f1 and HDRP/Lit material

Same here in 2022.2.4f1. EnableKeyword(“_EMISSION”) fixed it, thanks for the info MTandi! :slight_smile:

This bug still occur in URP lit material of unity 2023.1.6f1, and this solution also works. Thanks!