Search Unity

Prefab Mode Lighting

Discussion in 'Prefabs' started by noethis, Dec 13, 2018.

  1. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    105
    Just downloaded 2018.3 to try out the new prefab features. First thing I noticed was that as soon as I enter prefab mode the lighting is way darker and off. So then I set up the prefab environment scene in the project settings so that it would match my scene but it's still way off.

    I'm using a flat lighting approach where scene ambient color is full white--I'm guessing this has something to do with it? Even when I set the ambient color in the prefab environment scene it seems to not take that into effect. Since everything is flat and I'm coloring scenes in editor I absolutely need to see correct lighting/colors while in prefab mode. Am I doing something wrong?

    intended lighting vs prefab mode:
    1.JPG vs 2.JPG
     

    Attached Files:

  2. xidived

    xidived

    Joined:
    Aug 5, 2018
    Posts:
    3
    I have the same problem, and my prefabs look very different(with same light settings) in Unity Editor and in Android device. Maybe it is a bug of current version Unity?
     
  3. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12
    Same here, this really bothers me. I need to keep opening/closing prefab mode to see the changes because lighting looks completly different in prefab mode.
     
    Last edited: Dec 16, 2018
  4. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    We currently have an issue with Ambient lighting in Prefab Mode.
    Please make a bug report and paste the issue number in this thread so we have your use-cases to test with. Please note if you are using Scriptable Render Pipeline or not.

    It will be fixed in an upcoming patch.
     
    Joe-Censored and impulse9 like this.
  5. impulse9

    impulse9

    Joined:
    Sep 17, 2015
    Posts:
    12
    I've reported this and got assigned case number 1112259
     
  6. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    295
    Can confirm I have the exact same issue. Created a Stage Scene for Prefabs that only has a Direct Light and Ambient Light settings and the ambient light does not work.

    In addition, sometimes the Direct Light does not work either.
     
  7. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    295
    Any news on this, there has been 2 releases since this was reported, seems like a glaring oversight for a flagship feature of the new Prefab system.
     
  8. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,639
    We have a lot of issues to fix and can't do everything at once.

    For the specific issue here, case 1112259 just got into QA verification today (where they try to reproduce the bug before it's sent to developers). I guess they have a lot on their plate in QA as well.

    I wish we could make everything happen faster, but the reality is that some patience is needed.
     
    noethis likes this.
  9. CliffCawley

    CliffCawley

    Joined:
    Mar 30, 2009
    Posts:
    16
    I just encountered this one too, looking forward to the fix :)
     
  10. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    Can confirm this issue as well. Makes prefab mode unusable. Could we get an option to have "no light" in prefab mode?
     
  11. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    Use the SceneView lighting toggle as a workaround until this is fixed. The lighting toggle state is stored per Prefab opened in Prefab Mode.

     
  12. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    @Mads-Nyholm Thanks, first thing I tried :), doesn't work.

    Cannot confirm in general, but we use custom lights for Unto, the default lights are way way too expensive for 2D, and we can't bake our lighting for reasons I cannot fully recall... 2D sprites + our DoF shader stuff... something like that :).

    A thot, can I detect when the editor is in "prefab edit mode"? And, is the prefab edit mode located in world space relative to other scenes or in some new view space? Can I move a light to it?

    I'm asking b/c maybe I could turn on a full white light at the location of prefab only when editing. Thots?
     
  13. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    You have a couple of options.
    1) First try to add a light to the Environment scene (make sure the scene is assigned in Editor Settings)
    2) Or use
    PrefabStage.prefabStageOpened
    . Here you get passed the PrefabStage that has just been opened and can dynamically add environment objects by creating your GameObjects and moving them to
    prefabStage.scene
     
  14. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
  15. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    Excellent, thanks. I'll have a look as soon as I get a free window. Cheers!
     
  16. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    @Mads-Nyholm giving this a go today...

    1, Adding a light to the Environment scene doesn't seem to work, nor does a ground or anything else -- is this scene truly getting loaded on prefab edit? For clarification when you say 'Editor Settings' you mean Project Settings > Editor (tab), yes? Just want to make sure I'm not missing another place to set the Prefab scene.

    2, How do I wire up
    OnPrefabStageOpened
    ? I hung it off a MonoBehavior that is set to execute in edit mode and added it to a loaded GameObject but it never gets called... :|.
     
    Last edited: Apr 9, 2019
  17. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    247
    In your ExecuteInEditMode script, you need to assign your function to the prefabStageOpened event, like this:

    Code (CSharp):
    1. void Start()
    2. {
    3.     PrefabStage.prefabStageOpened += OnPrefabStageOpened;
    4. }
    5.  
    6. void OnPrefabStageOpened(PrefabStage prefabStage)
    7. {
    8.     // Do stuff here
    9.  
    10.     // Unsubscribe when done so you dont get multiple callbacks when re-entering prefab mode
    11.     PrefabStage.prefabStageOpened -= OnPrefabStageOpened;
    12. }
     
  18. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    Ahh... :)... thanks, will give it a go!

    I now get the event, and the prefab scene that I created and put a light in, appears to be loaded, but it is totally dark, no light at all.
     
  19. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    247
    I played around with it a little and found that I had to toggle the scene lighting *on* in prefab mode to see the added light (the little sun looking button at the top of the scene window). Also, make sure you are moving the light into the prefab scene.

    edit:
    Here is a complete working script that I added onto my prefab:
    Code (CSharp):
    1. using UnityEditor.Experimental.SceneManagement;
    2. using UnityEngine;
    3. using UnityEngine.SceneManagement;
    4. [ExecuteInEditMode]
    5. public class PrefabModeLight : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.         PrefabStage.prefabStageOpened += OnPrefabStageOpened;
    10.     }
    11.  
    12.     void OnPrefabStageOpened(PrefabStage prefabStage)
    13.     {
    14.         // Do stuff here
    15.         GameObject go = new GameObject();
    16.         Light directionalLight = go.AddComponent<Light>();
    17.         directionalLight.type = LightType.Directional;
    18.         directionalLight.intensity = 10;
    19.  
    20.         SceneManager.MoveGameObjectToScene(go, prefabStage.scene);
    21.  
    22.         // Unsubscribe when done so you dont get multiple callbacks when re-entering prefab mode
    23.         PrefabStage.prefabStageOpened -= OnPrefabStageOpened;
    24.     }
    25. }
    26.  
     
    Last edited: Apr 10, 2019
  20. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    182
    Thanks for digging into this... I think it's something to do with my custom 2D lights (see context early in thread)... I had everything working early, but this simply doesn't work for me :|.

    I'll keep hacking at it, and post back if I get anywhere.

    @UnityDesign As general feedback to any Unity UI designers that might come across this thread. The new prefab workflow indeed enables nesting prefabs, but at the expense of the more common in-line and bulk editing of prefabs. To me this feels like the wrong prioritization. I find the current prefab workflow so cumbersome that I'd greatly appreciate a way to turn it off and use the old system :|.
     
    Lars-Steenhoff likes this.
  21. unity_v6RHUHoRNjSj-Q

    unity_v6RHUHoRNjSj-Q

    Joined:
    Jun 2, 2019
    Posts:
    1
    I had the same problem. I created a scene with a few directional lights and used it as Prefab Editin Environment (Project Settings -> Editor)
     
    GlitchCrew likes this.
  22. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    105
    It's been about 8 months now and the ambient lighting issue in prefab mode still exists. Did I miss something or has it not been patched yet?

    EDIT: May have found the fix in the 2019.1.6 release notes (I'm on 2019.1.0). It seems that release notes are split between 2 different pages--the Download Archive (https://unity3d.com/get-unity/download/archive) and Patch Releases(https://unity3d.com/unity/qa/patch-releases)?
     
  23. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,639
  24. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,150
    Is this fix coming to 2018.4 LTS ?
     
    Rich_A likes this.
  25. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,639
    It has been in 2018.4 since 2018.4.4f1.
    Note, I believe it doesn't work if the environment scene is set to Auto in the lighting settings. If you set it to Baked and bake it, it should work.