- Home /
Question by
scarletshark · Apr 30, 2014 at 01:25 AM ·
c#editor-scriptingnullreferenceexceptionlightmapbeast
How do I resize the Lightmap Array via Editor Script?
I'm using the following code in an editor script to resize the LightmapSettings.lightmaps array:
//resize array based on room count
LightmapData[] Lightmaps = LightmapSettings.lightmaps;
print (Lightmaps.Length); // returns 0
System.Array.Resize (ref Lightmaps, RoomCount);
print (Lightmaps.Length); // returns 3 (this is correct)
LightmapSettings.lightmaps = Lightmaps; //NullReferenceException
I got this far from this answer by Mike 3. Any thoughts on why this may not be working?
Comment
Answer by CrazyDoctor · Sep 08, 2014 at 10:47 AM
Maybe null reference because lightmaps array has one or more null elements.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143915im_/https://answers.unity.com/themes/thub/images/avi.jpg)