Follow

How can I get the baking type of a light component through scripting?

Symptoms

  • The API to get the baking type directly is not available.

Cause

The scripting API does not have a direct method to get the baking type of the lights configured in the scene.

Resolution

You can use the SerializedObject/SerializedProperty system and access the m_Lightmapping property.

Example:

 
Light objLight;
SerializedObject serialObj = new SerializedObject(objLight);
SerializedProperty lightmapProp = serialObj.FindProperty("m_Lightmapping");
switch (lightmapProp.intValue) {
   case 1:
     Debug.Log ("Light set to Mixed.");
   break;
   case 2:
     Debug.Log ("Light set to Baked.");
   break;
   case 4:
     Debug.Log ("Light set to Realtime.");
   break;
}

 

More Information

This article applies to Unity versions 5.0+

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.