- Home /
Is there a way to set an object's "Scale In Lightmap" in a script?
The Lightmapping window's Object tab has a "Scale In Lightmap" parameter, is there a way to set its value in a script?
The other parameters ("Static" and "Atlas") are available through the GameObject and MeshRenderer classes respectively but I've been unable to find any information on how to access "Scale In Lightmap".
Answer by Aras · Jan 10, 2011 at 07:32 PM
It's not exposed as an API (wouldn't be very useful at runtime), but you can access and modify it from Editor scripts via SerializedProperty. Something like:
SerializedObject so = new SerializedObject (go.renderer);
so.FindProperty("m_ScaleInLightmap").floatValue = 0;
so.ApplyModifiedProperties();
It would be nice if this was exposed via an editor API, if you write scripts that instance custom meshes in the editor then it's a bit frustrating to have to track down and write in little hacks like this to get at everything.
This is now obsolete and setting via ren.lightmapScaleOffset = scaleOffset; does not work are there any work arounds?
i tried it in unity 2018.3.5,but it does't work...
Answer by pawel_piotrowski · Dec 04, 2016 at 10:48 AM
I managed to get it to work:
GameObject test = GameObject.Find ("bread_1_1");
Renderer rend = test.GetComponent<Renderer>();
SerializedObject so = new SerializedObject (rend);
so.FindProperty("m_ScaleInLightmap").floatValue = 50;
so.ApplyModifiedProperties();
Your answer
![](https://koobas.hobune.stream/wayback/20220613094159im_/https://answers.unity.com/themes/thub/images/avi.jpg)