Search Unity

How to adjust baked shadow angle from script?

Discussion in 'Scripting' started by ZoltanErdokovy, Sep 17, 2012.

  1. ZoltanErdokovy

    ZoltanErdokovy

    Joined:
    Aug 23, 2012
    Posts:
    102
    Distant lights have two properties which affect shadows in lightmaps: Shadow Angle and
    Shadow Samples. How could I adjust these properties of from script?
     
  2. ZoltanErdokovy

    ZoltanErdokovy

    Joined:
    Aug 23, 2012
    Posts:
    102
    This is one way to do it:

    Code (csharp):
    1. SerializedObject serialObj = new SerializedObject(lightGameObject.light);
    2. SerializedProperty shadowSampleProp = serialObj.FindProperty("m_ShadowSamples");
    3. shadowSampleProp.intValue = 10;
    4. SerializedProperty shadowAngleProp = serialObj.FindProperty("m_ShadowAngle");
    5. shadowAngleProp.floatValue = 10;
    6. serialObj.ApplyModifiedProperties();