Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Soft Shadow Radius

Discussion in 'Scripting' started by UnityLighting, Jul 4, 2017.

  1. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,793
    Hello all

    I want to access to "baked Shadow Radius" of Light component.

    how can i do that ?


    try.jpg
     
  2. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    55
    Hi, did you figure out how to access this value in a script? i'd be interested in this as well.

    thanks!
     
  3. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    55
    figured it out...

    Code (CSharp):
    1.        
    2. Light l = g.GetComponent<Light>();
    3.  SerializedObject serialObj = new SerializedObject(l);
    4. SerializedProperty bakedShadowRadiusProp = serialObj.FindProperty("m_ShadowRadius");
    5. // here the magic happens
    6. bakedShadowRadiusProp.floatValue = myTarget.softshadowRadius;
    7. serialObj.ApplyModifiedProperties();
    8.  
    also loot at:
    https://answers.unity.com/questions/163585/how-can-i-access-lightmapping-settings-for-a-light.html
    https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditor/LightEditor.cs