Search Issue Tracker

Fixed in 14.0.2

Votes

3

Found in [Package]

12.0.0

Issue ID

1387201

Regression

Yes

[URP] NullReferenceException error is thrown when the scene contains a Light 2D and a Sprite with a Composite Shadow Caster 2D

Package: Scriptable Render Pipeline Universal

-

How to reproduce:
1. Open the user-submitted project
2. Open the scene "ErrorTest" (Assets/ErrorTest/ErrorTest.unity)
3. Open the Scene view window (Window > General > Scene)
4. in the Hierarchy window, select the GameObject "Square"
5. Inspect the Console window (Window > General > Console)

Expected result: No errors are seen in the Console
Actual result: A NullReferenceException error is spammed in the Console

Reproducible with: 12.0.0 (2021.2.0b9), 12.1.2 (2021.2.6f1), 13.1.3 (2022.1.0b2)
Not reproducible with: 7.7.1 (2019.4.34f1), 10.7.0 (2020.3.25f1), 12.0.0 (2021.2.0b8)

Error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.Universal.ShadowCasterGroup2D.CacheValues () (at Library/PackageCache/com.unity.render-pipelines.universal@12.0.0/Runtime/2D/Shadows/ShadowCasterGroup2D.cs:15)
UnityEngine.Rendering.Universal.ShadowCasterGroup2DManager.CacheValues () (at Library/PackageCache/com.unity.render-pipelines.universal@12.0.0/Runtime/2D/Shadows/ShadowCasterGroup2DManager.cs:42)

  1. Resolution Note (fix version 14.0.2):

    Fixed in: 14.0.2 (2022.2.0a9)

Comments (1)

  1. z3nth10n

    Feb 17, 2022 23:08

    You must call CompositeShadowCaster2D.RegisterShadowCaster2D per each subtransform you add with a ShadowCaster2D.

    CompositeShadowCaster2D compositeShadow = source.transform.gameObject.GetComponent<CompositeShadowCaster2D>();
    if (compositeShadow == null)
    {
    compositeShadow = transform.gameObject.AddComponent<CompositeShadowCaster2D>();
    }

    compositeShadow.RegisterShadowCaster2D(shadow);

    Something like that must work.

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.