Search Unity

Changing Global Illumination settings programatically.

Discussion in 'Scripting' started by Murcho, Dec 7, 2015.

  1. Murcho

    Murcho

    Joined:
    Mar 2, 2009
    Posts:
    309
    I'm trying to find a way to turn Precomputed Realtime and Baked GI (along with some other lighting settings) on and off programatically from an Editor script. I've dug through the documentation pretty extensively and nothing seems to do the trick.

    Classes I've covered :
    • LightmapEditorSettings
    • Lightmapping
    • LightmapParameters
    • LightmapSettings
    • LightmapData
    • DynamicGI
    I don't think I've missed any classes that could be in control of theses settings, but it's more than possible.

    Does anyone know of a way to turn these options on and off programatically?
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Probably by using reflection and and executing the same code that the unity editor windows use(internally).
    You can use a tool called ILSpy to find out what's hiding inside the editor classes.
    http://ilspy.net/
    Open the unity editor.dll and search for EnlightenBakeSettings()

    (C:\Program Files\Unity5\Editor\Data\Managed\UnityEditor.dll)
    Im currently on my way to test it but it should work.
     
  3. Diablo404

    Diablo404

    Joined:
    Mar 15, 2013
    Posts:
    136
  4. Murcho

    Murcho

    Joined:
    Mar 2, 2009
    Posts:
    309
    Thanks for the tips guys, I'll check out the reflection/decompile method. I had thought about going down that route, but I figured there might actually be an API I was missing.

    Unity Devs if you happen to read this, is there a reason these API's aren't exposed to the end user, and if not could we get them put in?