Hi there,
I’m trying to make an assetbundle from a scene that has lighting baked into lightmaps and it’s not loading correctly.
The scene with all the geometry is loading correctly, but all the static objects that should receive a lightmap are marked non static and also the Contribute Global Illumination is checked off. When debugging in editor using the Scene View (Baked Lightmap) I can see that the lightmaps are assigned, but in Shaded mode the shader doesn’t seem to use the lightmap affect.
Lastly, if I select any of the objects and reassign the exact same shader (Standard) while still in play mode… it fixes the issue and shows the affect of lightmap on the object.
I can maybe hack it and iterate over every object in the scene and reassign the shaders again in runtime, but it just seems like a bug that needs to be fixed. or I’m possibly doing something else wrong.
Thank you.
For what it’s worth… here’s the hack that fixed the issue for me.
I just run it after loading the scene, but you have to wait till it’s actually loaded with await or coroutine.
MeshRenderer[] rnds = GameObject.FindObjectsOfType<MeshRenderer>();
Shader shader = Shader.Find("Standard");
foreach (MeshRenderer rnd in rnds)
{
Material mat = rnd.sharedMaterial;
Shader origShader = mat.shader;
mat.shader = shader;
mat.shader = origShader;
}
Does anyone has a better solution ?
This seems to work 90% of the time, but with some shaders it’s not fully working.
I’m having the same issue! Did you find a soultion? I’m using URP
Did you figure out a solution for this?