- Home /
Resize lightmaps array??
I'm making a "Beast Helper" script, that save gameobjects list and tiling info for each lightmap, and you can restore it later. Everything seems to work, but I have a problem: LightMapSettings.Lightmaps[] cannot be resized... (The length property is read only).
I need to set the number of lightmaps from script, otherwise my script can cause Out of index errors when trying to set a number of lightmaps bigger than LightMapSettings.Lightmaps.Length...
Any ideas?? Thanks
Answer by Mike 3 · Sep 28, 2010 at 12:35 PM
Store the array reference in a temporary variable, resize it (Array.Resize - you can't modify .Length in a normal array either), then push it back into the variable
In c# it'd look something like this:
LightmapData[] lightmaps = LightMapSettings.Lightmaps;
System.Array.Resize(lightmaps, newSize);
LightMapSettings.Lightmaps = lightmaps;
Thanks for the quick response, I will test it now...
$$anonymous$$ike, I've tried this solution and it returns a null reference exception at Light$$anonymous$$apSettings.Lightmaps = lightmaps;
Please see my Unity Answers thread for details
Your answer
![](https://koobas.hobune.stream/wayback/20220613074203im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mixing baked and real-time shadows and real-time performance 1 Answer
Lightmapping problem 0 Answers
Do I still need lightmaps? 1 Answer
Emission baked Black, lightmap very blocky? 1 Answer
Lightmapping issues in Unity.. 1 Answer