Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug (Case 1360871) Universal.ShadowCasterGroup2DManager throws an error when exiting play-mode

Discussion in '2021.2 Beta' started by KamilCSPS, Aug 26, 2021.

  1. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Regression from B8;

    After upgrading our project to B9, when exiting play-mode, we now have the following error:


    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Rendering.Universal.ShadowCasterGroup2DManager.OnPlayModeStateChanged (UnityEditor.PlayModeStateChange state) (at Library/PackageCache/com.unity.render-pipelines.universal@12.0.0/Runtime/2D/Shadows/ShadowCasterGroup2DManager.cs:30)
    UnityEditor.EditorApplication.Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange state) (at <9de32d58e117474d9df95577a7ba5c6d>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)


    Case 1360871
     
    tonytopper, LeonhardP and adamgolden like this.
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Just beat me to it - I let the bug report finish uploading the repro anyway (URP template).

    Edit: 1360874
     
    Last edited: Aug 26, 2021
  3. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Solution for anyone that wants to get around it for now.. in your project, scroll down to Packages in Project window, right-click Universal RP, click Show In Explorer. Then copy the folder to a location of your choosing. Then open that folder/Runtime/2D/Shadows/ShadowCasterGroup2DManager.cs, replace OnPlayModeStateChanged function with this:
    Code (CSharp):
    1.         private static void OnPlayModeStateChanged(PlayModeStateChange state)
    2.         {
    3.           if (s_ShadowCasterGroups != null)
    4.           {
    5.               if (state == PlayModeStateChange.ExitingEditMode || state == PlayModeStateChange.ExitingPlayMode)
    6.                   s_ShadowCasterGroups.Clear();
    7.           }
    8.         }
    Then open Package Manager, click the +, click "Add package from disk" and browse to that folder/package.json file. The error should then be gone. You can pick the unedited/official version again whenever from Package Manager.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm getting this issue too. When will the package update happen for URP?
     
  5. proepkess

    proepkess

    Joined:
    Dec 26, 2016
    Posts:
    11
    Another way to get around this is to add "ShadowCaster2D"-Component to a gameobject in your scene
     
    adamgolden likes this.
  6. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    adamgolden and hippocoder like this.
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    TBH it is a bit of a nooby coding mistake :D Looking at the source I can't imagine why anyone wouldn't think that would cause problems even while typing it. It's just plain sloppy really. Beta is beta though so I'll go back in my box.
     
  8. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    I agree, weird that it passed in the QA crack... but...

    A bug report is a bug report and I wouldn't mind having a RTX 3090 :D
     
  9. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I just had occasion to try this - good tip. The GameObject it's attached to must also be active in the scene and the component must be enabled at the time the error would be thrown.
     
  10. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    Crack? You make it sound like they do QA..
     
  11. kamil-dawidow

    kamil-dawidow

    Joined:
    May 29, 2018
    Posts:
    6
    Is any fix coming?
     
  12. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    You are probably thinking of UE.
     
  13. Viceroy_

    Viceroy_

    Joined:
    Jul 13, 2016
    Posts:
    1
    Dudes if you hate Unity so much why are you on the forum?
     
    KamilCSPS and adamgolden like this.
  14. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    Because I look for answers to these kinds of bugs.

    Believe me, if I could migrate my project to unreal I'd have abandoned unity ages ago.
     
  15. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    FYI, There's a neat feature called "Ignore" when you click a user that you feel doesn't contribute constructively to conversations.
     
  16. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Not to speak of anyone around here in particular, but in the industry it's often what's called "proliferation". I've seen it - in person, in real life - large rooms full of people getting paid good money to spend all day writing fake comments, reviews, giving likes, hating, shaming, tweeting, lying and so on. Sometimes it's bots or auto-responder style scripts, which is partially to blame for why a lot of comments around the internet don't make sense or have anything to do with what's being talked about (since accuracy with that stuff isn't a perfect science, yet).

    Of course, that's not always the case, some people doing it are honest but have had a run of bad luck, or are the type to blame a car they wreck for an accident, or just plain ignorant, or parotting some comment they read - so nobody calls it out. Besides that, everyone's entitled to an opinion - and at the end of the day it's up to each of us to decide whose opinion to value. And if it's really offensive ..as noted above, there is the Ignore feature, I use that one in real life too :D
     
  17. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    adamgolden likes this.