- Home /
Change scale in lightmap (Prefab property) by script
Hi,
I do a script which change the scale in lightmap by script with this function :
private void ScaleInLightmapAll (GameObject go)
{
//Check if he got a renderer
if (go.renderer != null) {
//Serialized my object to allow to modify every property in it
SerializedObject so = new SerializedObject (go.GetComponent<Renderer> ());
// Debug.Log ("Scale value : " + so.FindProperty ("m_ScaleInLightmap").floatValue.ToString ());
//Find the property and modify them
so.FindProperty ("m_ScaleInLightmap").floatValue = m_nScaleInLightmap;
// Debug.Log ("Scale value after : " + so.FindProperty ("m_ScaleInLightmap").floatValue);
//Apply the modified properties
Debug.Log ("succes ? " + so.ApplyModifiedProperties ()); //Send true but this is working ? oO
// Debug.Log ("Scale value after : " + so.FindProperty ("m_ScaleInLightmap").floatValue);
}
}
All my debug line seems ok before and after but when I bake my lightmap with another script, my lightmap is bake with the initial value of each prefab (1).
Someone got an idea on this, it can be a good thing ;)
I create a Unity forum thread to centralize the answer, so if someone got a solution, my problem is more explain on the forum. So if someone got knowledges on AssetDatabase methods, thanks to help me é_è The link : http://forum.unity3d.com/threads/150200-Changing-prefab-property-by-script
Your answer
Follow this Question
Related Questions
Multiple lightmaps / 1 scene 1 Answer
SerializedObject and modification 1 Answer
Why does the prefabOverride not work on fields marked as SerializeField? 0 Answers
Just one lightmap per level 0 Answers
Lighting is turned off when baking GI 0 Answers