Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.55k stars 343 forks source link

Bug in the tile palette if added a Gameobject with a ShadowCaster2d #299

Open valentinbarral opened 3 years ago

valentinbarral commented 3 years ago

Hello,

I'm making a 2d tile-based platformer, and I wanted to use the Gameobject Brush to place the gameobjects on the grid. The problem appears when I try to place a Gameobject on the palette. Although the mechanism works fine, an incorrect texture appears in the palette, as if a sprite was missing. Still you can select the tile and paint it on the tilemap and the gameobject is placed correctly. You go into play mode and everything seems to work fine, but when you exit the editing screen is black and an error appears in console (I paste it after the video). However, if at this point you delete the gameobject from the palette, the error disappears automatically and the editor view works again. In the video below you can see the whole process.

https://user-images.githubusercontent.com/38099967/130319058-4fd34097-791c-4745-8729-b2ae75afa2a4.mp4

I think the error is related to my objects including a ShadowCaster2d, and for some reason it crashes the editor. This only happens if the palette is visible when you press Play, if it is not the editor works correctly.

I am using 2d-extras version 2.2.0 and version 2021.1.7f1.

The error in console:

ArgumentNullException: Value cannot be null.
Parameter name: mesh
UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material, System.Int32 submeshIndex, System.Int32 shaderPass, UnityEngine.MaterialPropertyBlock properties) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material, System.Int32 submeshIndex, System.Int32 shaderPass) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material, System.Int32 submeshIndex) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.Experimental.Rendering.Universal.ShadowRendering.RenderShadows (UnityEngine.Experimental.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmdBuffer, System.Int32 layerToRender, UnityEngine.Experimental.Rendering.Universal.Light2D light, System.Single shadowIntensity, UnityEngine.Rendering.RenderTargetIdentifier renderTexture) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Shadows/ShadowRendering.cs:145)
UnityEngine.Experimental.Rendering.Universal.ShadowRendering.PrerenderShadows (UnityEngine.Experimental.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmdBuffer, System.Int32 layerToRender, UnityEngine.Experimental.Rendering.Universal.Light2D light, System.Int32 shadowIndex, System.Single shadowIntensity) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Shadows/ShadowRendering.cs:43)
UnityEngine.Experimental.Rendering.Universal.RendererLighting.RenderLightSet (UnityEngine.Experimental.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, System.Int32 blendStyleIndex, UnityEngine.Rendering.CommandBuffer cmd, System.Int32 layerToRender, UnityEngine.Rendering.RenderTargetIdentifier renderTexture, System.Collections.Generic.List`1[T] lights) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Passes/Utility/RendererLighting.cs:202)
UnityEngine.Experimental.Rendering.Universal.RendererLighting.RenderLights (UnityEngine.Experimental.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmd, System.Int32 layerToRender, UnityEngine.Experimental.Rendering.Universal.LayerBatch& layerBatch, UnityEngine.RenderTextureDescriptor& rtDesc) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Passes/Utility/RendererLighting.cs:526)
UnityEngine.Experimental.Rendering.Universal.Render2DLightingPass.DrawLayerBatches (UnityEngine.Experimental.Rendering.Universal.LayerBatch[] layerBatches, System.Int32 batchCount, System.Int32 startIndex, UnityEngine.Rendering.CommandBuffer cmd, UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData, UnityEngine.Rendering.FilteringSettings& filterSettings, UnityEngine.Rendering.DrawingSettings& normalsDrawSettings, UnityEngine.Rendering.DrawingSettings& drawSettings, UnityEngine.RenderTextureDescriptor& desc) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Passes/Render2DLightingPass.cs:150)
UnityEngine.Experimental.Rendering.Universal.Render2DLightingPass.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/2D/Passes/Render2DLightingPass.cs:284)
UnityEngine.Rendering.Universal.ScriptableRenderer.ExecuteRenderPass (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.ScriptableRenderPass renderPass, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/ScriptableRenderer.cs:732)
UnityEngine.Rendering.Universal.ScriptableRenderer.ExecuteBlock (System.Int32 blockIndex, UnityEngine.Rendering.Universal.ScriptableRenderer+RenderBlocks& renderBlocks, UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData, System.Boolean submit) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/ScriptableRenderer.cs:706)
UnityEngine.Rendering.Universal.ScriptableRenderer.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/ScriptableRenderer.cs:561)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.CameraData cameraData, System.Boolean anyPostProcessingEnabled) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/UniversalRenderPipeline.cs:391)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/UniversalRenderPipeline.cs:301)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List`1[T] cameras) (at Library/PackageCache/com.unity.render-pipelines.universal@11.0.0/Runtime/UniversalRenderPipeline.cs:256)
UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List`1[T] cameras) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, System.Collections.Generic.List`1[T] renderRequests, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at <6a104889781c465ca00c12d0953583e2>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
ChuanXin-Unity commented 3 years ago

Hi, would it be possible for you to file a bug report with your project using the Unity Bug Reporter and post the case number here? This would help us take a better look at this issue. Thanks!

valentinbarral commented 3 years ago

Hi, would it be possible for you to file a bug report with your project using the Unity Bug Reporter and post the case number here? This would help us take a better look at this issue. Thanks!

Hi, the case number is 1360941.

Regards.

ChuanXin-Unity commented 3 years ago

Thanks! We will check this out!

ChuanXin-Unity commented 3 years ago

Hi, this looks like an issue with the URP package. We will need to fix this issue there. To get the fix, you will need to get a newer version of the URP package/update your Unity Editor version.