Question by
RealtimeGI · Apr 11, 2017 at 02:30 PM ·
lightmap
add lightmapdata failure in real time(unity5.6)
I'm baked lightmap in A scene, I think in B scene(no lightmapdata) real-time load prefab and lightmap. I tried, lightmapindex and offset has been applied.But the shadow can't be rendered.
LightmapData[] lightmaps = new LightmapData[1];
lightmaps[0].lightmapColor = Resources.Load("lightmapColor", typeof(Texture2D)) as Texture2D;
lightmaps[0].shadowMask = Resources.Load("shadowMask", typeof(Texture2D)) as Texture2D;
LightmapSettings.lightProbes = null;
LightmapSettings.lightmapsMode = LightmapsMode.NonDirectional;
LightmapSettings.lightmaps = lightmaps.ToArray();
render.lightmapIndex = lightmapIndex;
render.lightmapScaleOffset = lightmapScaleOffset;
render.enabled = true;
Comment
I met the same question by Unity 2017.2~ so it seems a bug of Unity?
Your answer

Follow this Question
Related Questions
Lights Stopped Working, No Lights Work, New Lights Won't work Either. 0 Answers
Precomputed GI Baking GI Problems - Hardedges, different information of light in meshes and tiles. 0 Answers
Set lightmap index of static baked renderer have no effect on runtime 0 Answers
How to import texture to be used as Occlusion map? 0 Answers