Search Unity

Bug Addressables, URP Shaders and WebGL

Discussion in 'Universal Render Pipeline' started by WavyRancheros, Jun 2, 2023.

  1. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    I have encountered a problem with Addressables and URP shaders in WebGL.

    When I load an asset, it loads successfully (geometry, materials, shaders and all), BUT it is invisible.
    In the Unity Editor, I can re-select the shader again from the dropdown in the material inspector, and suddenly the object is visible again.

    This happens on no other platform.

    Unity 2022.2.21f1
    Addressables 1.21.12
    URP 14.0.7

    Does anyone have an idea what's causing this?
     
  2. felipemoreno

    felipemoreno

    Joined:
    Oct 23, 2013
    Posts:
    4
    Same problem here. Have you found a fix?
     
  3. felipemoreno

    felipemoreno

    Joined:
    Oct 23, 2013
    Posts:
    4
    if someone is facing this same issue, I had to make an awful workaround:
    Just start this coroutine right after you load your addressable scene.

    Code (CSharp):
    1.     public IEnumerator RefreshMaterials()
    2.     {
    3.         yield return new WaitForEndOfFrame();
    4.         Debug.Log("Refreshing materials");
    5.         var renderers = GameObject.FindObjectsOfType<MeshRenderer>();
    6.        
    7.         foreach (var meshRenderer in renderers)
    8.         {
    9.             foreach (var material in meshRenderer.materials)
    10.             {
    11.                 material.shader = Shader.Find(material.shader.name);
    12.             }
    13.         }
    14.     }
     
    yty likes this.
  4. yty

    yty

    Joined:
    Aug 10, 2009
    Posts:
    82
    2022.3.5 WebGL + forward render + addressables

    There is also this issue.