Search Issue Tracker

Fixed in 5.4.0

Votes

4

Found in

5.2.1p2

Issue ID

733508

Regression

No

[API] add API to set Sun in Environment Lighting and manual setting does not save

Global Illumination

-

Steps to reproduce:

1) open project
2) go into window-lighting-scene
3) set "Sun" to prefab from hierarchy
4) save and close unity
5) open project
6) check the lighting-scene

expected: assigned sun
actual results: none

note: works with nonprefabs and if you drag straight from project tab instead of hierarchy

Comments (7)

  1. wood333

    Mar 26, 2017 14:52

    I don't know what version this was supposed to be fixed for, but the bug is still in 5.4.1f1.

  2. Yukinohito

    Oct 09, 2016 04:37

    But where is scripting api to set sun object via script? Still missing!

  3. blexbox

    Aug 31, 2016 16:58

    vote here if you want this to be exposed and have access by code:

    https://feedback.unity3d.com/suggestions/option-to-set-sun-light-via-script

  4. blexbox

    Aug 31, 2016 16:49

    Update: finally the workaround described work for me once I assign the new invisible directional light as the sun on the lighting panel, but it is not automatically chosen. Good think is that this assignment seems to be preserved after been saved so when the scene is re-opened, it is still there and its parent (which is the real visible sun light source I want to be considered as such) seems to behave as it should. Thank you BENAKIN486.

    Note: it could be very good to be able to assign this from the code, like RenderingSettings.Sun = MyDirectionalLight; I haven't seen this as an option so far, no clue if it will be on a future Unity update (IT SHOULD!)

  5. blexbox

    Aug 23, 2016 16:39

    Still not working for me, even with the workaround.

    My asset has a directional light inside which after been set as the sun on the Lighting panel / Scene tab, it is simply unassigned again after scene is reloaded.

  6. CapeGuyBen

    Jul 29, 2016 11:03

    There's a suitable workaround to this issue which takes advantage of Unity's default behaviour of using the brightest light (original source of workaround: http://answers.unity3d.com/questions/936234/add-light-source-to-sun-in-skybox-with-unity-5-by.html#, see NathanWarden's answer)

    1. select the light you wish to use as your sunlight in the hierarchy
    2. right click and choose light->Directional Light (this will create a child directional light)
    3. select the new light
    4. Ensure the light has an identity transform (so it always points the same way as your parent sun light instance)
    5. Increase the light's intensity to 8 (max)
    6. Change the light's culling mask to 'nothing'

    The new light will now always be chosen as the sun light.

  7. CapeGuyBen

    Jul 29, 2016 10:55

    FYI. I've just tested this and it isn't fixed in Unity 5.4.0f3. My sun setting for the environment lighting is not preserved between reloads of the editor. As described, the sun light I'm using is within a prefab instance.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.