My guess was that it should be enough with something like this:
var myLM : Texture2D;
LightmapSettings.lightmaps*.lightmapFar = myLM;*
Being i a valid index, of course. It doesn’t work as I expected. In fact, when printing the .name of that lightmapFar, before and after the assignation, the same original name is given. What surprises me most is that, while in play mode, I can assign the texture manually in the lightmapper interface and it gets correctly updated. Anyone knows how should I do it in order to make it work in runtime from a script? Thanks!
Hi there! I just got such a thing working the other week through assetBundles, below is an adaptation that should work for you.
var myLMs : Texture2D[] = //populate your custom lightmaps
var lightmaparray : LightmapData[] = LightmapSettings.lightmaps;
for (var i=0; i < lightmaparray.Length; i++) {
var mapdata : LightmapData = new LightmapData();
mapdata.lightmapFar = myLMs
lightmaparray = mapdata; mapdata = null; } LightmapSettings.lightmaps = lightmaparray; I’m actually a C# guy, so please forgive if I’ve made any mistakes in translating to js, but I believe this should work.