Search Unity

Changing "Lighting Data Asset" at runtime?

Discussion in 'Scripting' started by bromske, Jan 27, 2016.

  1. bromske

    bromske

    Joined:
    Sep 11, 2012
    Posts:
    28
    Hello,

    is there a way to change the "Lighting Data Asset" after or before a scene is loaded?

    I have several baked lightmaps, but only switching the lightmaps dosn't work.
    It works only, when i use the right Lighting Data Asset.

    thx for help
     
  2. hacaro76

    hacaro76

    Joined:
    Oct 14, 2015
    Posts:
    25
    I'm interested too anyone can help us ?
    Thanks in advance
     
  3. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    360
    me too need help
     
  4. bromske

    bromske

    Joined:
    Sep 11, 2012
    Posts:
    28
    Is there really no way to use different lightmaps for a scene where some static objects are different :( (in Unity5)
    Do I really need to create different scenes for all little changes in one scene?
    You can't be serious :(

    This is a bis step backwards from U4 to U5 :(
     
  5. rickchow

    rickchow

    Joined:
    Jan 17, 2017
    Posts:
    1
    I need help too!Still no solution?
     
  6. xandelee

    xandelee

    Joined:
    Sep 12, 2013
    Posts:
    29
    Lightmapping.lightingDataAsset = Resources.Load ("Map 1 - Sun/LightingData", typeof(LightingDataAsset)) as LightingDataAsset;

    Funny think is that this line work in the editor but when building for android it gives me
    The name 'LightingDataAsset' does not denote a valid type ('not found'). Did you mean 'UnityEngine.LocationServiceStatus'?


    So you still can't change the lightingDataAsset via script?
     
  7. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
  8. amcakebread

    amcakebread

    Joined:
    Nov 8, 2016
    Posts:
    28
    any chance of ever getting this mess sorted out? I have one scene and various rooms that I want to apply lighting to when I switch between them. Why on earth would anyone think that being restricted to one light map per scene is remotely sensible, and why make it close to impossible to manually swap light maps? This has become a real problem on my project so any short term suggestion for a fix would be appreciated
     
  9. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    647
    Hello Is there actual way to change Lightnig Data Asset for scene on runtime? I'm using realtime GI precomputed only and I need possiblity to change lightning data asset in runtime not only by drag and drop in editor
     
  10. canyon_gyh

    canyon_gyh

    Joined:
    Aug 15, 2018
    Posts:
    48
    Have you solved this problem?(Changing "Lighting Data Asset" at runtime?)
     
  11. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    The lighting data asset is effectively just a collection of data that gets assigned to renderers when the scene loads (refer to https://github.com/NewBloodInteractive/com.newblood.lightdata for information on its structure). There's nothing preventing you from storing that data somewhere at runtime and recreating that functionality.

    After you assign new values to LightmapSettings.lightmaps and LightmapSettings.lightmapsMode, you then just need to iterate over all of your lightmapped renderers and assign the appropriate lightmapIndex and lightmapScaleOffset values (which is exactly what Unity does when it loads the lighting data asset).
     
  12. canyon_gyh

    canyon_gyh

    Joined:
    Aug 15, 2018
    Posts:
    48
    How do you use C# to reback the Probes Light Data (likes LightProbesGroup) and restore these Probes ? Dynamic object need these lights(But real lights),Unity2019.3 or New
     
    Last edited: May 22, 2021
  13. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
  14. canyon_gyh

    canyon_gyh

    Joined:
    Aug 15, 2018
    Posts:
    48
    Last edited: May 22, 2021
  15. y-iwanaga

    y-iwanaga

    Joined:
    Jul 2, 2021
    Posts:
    23
    Does it mean that in Unity today, it is not possible to set all light environments by loading and applying template scene assets and light-related data created in another scene?
     
  16. nice2000

    nice2000

    Joined:
    Jan 23, 2016
    Posts:
    5
  17. soumyadeep-ch

    soumyadeep-ch

    Joined:
    Sep 20, 2022
    Posts:
    1
    Last edited: Feb 22, 2023
    DBarlok likes this.