PrefabLightmapping
PrefabLightmapping copied to clipboard
"Index was outside the bounds of the array"
I'm getting the following error, Can you advise?
IndexOutOfRangeException: Index was outside the bounds of the array.
PrefabLightmapData.GenerateLightmapInfo (UnityEngine.GameObject root, System.Collections.Generic.List1[T] rendererInfos, System.Collections.Generic.List
1[T] lightmaps, System.Collections.Generic.List1[T] lightmapsDir, System.Collections.Generic.List
1[T] shadowMasks, System.Collections.Generic.List`1[T] lightsInfo) (at Assets/Scripts/PrefabLightmapData.cs:245)
PrefabLightmapData.GenerateLightmapInfo () (at Assets/Scripts/PrefabLightmapData.cs:182)
Something is off, I'd recommend removing the script and adding it again to the prefab and rebake
Hi bro! A value of 0xFFFE is internally used for objects that have their scale in lightmap set to 0; they affect lightmaps, but don't have a lightmap assigned themselves.
https://docs.unity3d.com/ScriptReference/Renderer-lightmapIndex.html
Hi bro! A value of 0xFFFE is internally used for objects that have their scale in lightmap set to 0; they affect lightmaps, but don't have a lightmap assigned themselves.
https://docs.unity3d.com/ScriptReference/Renderer-lightmapIndex.html
I am not following, what is this in reference to?
I fixed this issue by follow this reference, This issue triggered by "scale in lightmap set to 0"
I fixed this issue by follow this reference, This issue triggered by "scale in lightmap set to 0"
Feel free to make a pull request or give us a snipet to include : )
OK, as soon as possible
if (renderer.lightmapScaleOffset != Vector4.zero)
{
//1ibrium's mod : https://docs.unity3d.com/ScriptReference/Renderer-lightmapIndex.html
if(renderer.lightmapIndex < 0 || renderer.lightmapIndex == 0xFFFE) continue;
info.lightmapOffsetScale = renderer.lightmapScaleOffset;
Texture2D lightmap = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapColor;
Texture2D lightmapDir = LightmapSettings.lightmaps[renderer.lightmapIndex].lightmapDir;
Texture2D shadowMask = LightmapSettings.lightmaps[renderer.lightmapIndex].shadowMask;
info.lightmapIndex = lightmaps.IndexOf(lightmap);
if (info.lightmapIndex == -1)
{
info.lightmapIndex = lightmaps.Count;
lightmaps.Add(lightmap);
lightmapsDir.Add(lightmapDir);
shadowMasks.Add(shadowMask);
}
rendererInfos.Add(info);
}
Thanks! I'll push it