Error on Player Build


It shows…

ArgumentNullException: Value cannot be null.
Parameter name: mesh
at UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material, System.Int32 submeshIndex, System.Int32 shaderPass, UnityEngine.MaterialPropertyBlock properties) [0x0008a] in C:\build\output\unity\unity\Runtime\Export\Graphics\RenderingCommandBuffer.cs:493
at UnityEngine.Rendering.CommandBuffer.DrawMesh (UnityEngine.Mesh mesh, UnityEngine.Matrix4x4 matrix, UnityEngine.Material material, System.Int32 submeshIndex, System.Int32 shaderPass) [0x00001] in C:\build\output\unity\unity\Runtime\Export\Graphics\RenderingCommandBuffer.cs:498
at UnityEngine.Rendering.Universal.ShadowRendering.RenderSelfShadowOption (UnityEngine.Rendering.CommandBuffer cmdBuffer, System.Int32 layerToRender, UnityEngine.Rendering.Universal.Light2D light, System.Collections.Generic.List1[T] shadowCasters, UnityEngine.Material projectedUnshadowMaterial, UnityEngine.Material spriteShadowMaterial, UnityEngine.Material spriteUnshadowMaterial, UnityEngine.Material geometryShadowMaterial, UnityEngine.Material geometryUnshadowMaterial) [0x000e8] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Shadows\ShadowRendering.cs:285 at UnityEngine.Rendering.Universal.ShadowRendering.RenderShadows (UnityEngine.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmdBuffer, System.Int32 layerToRender, UnityEngine.Rendering.Universal.Light2D light, System.Single shadowIntensity, UnityEngine.Rendering.RenderTargetIdentifier renderTexture) [0x001fe] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Shadows\ShadowRendering.cs:386 at UnityEngine.Rendering.Universal.ShadowRendering.PrerenderShadows (UnityEngine.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmdBuffer, System.Int32 layerToRender, UnityEngine.Rendering.Universal.Light2D light, System.Int32 shadowIndex, System.Single shadowIntensity) [0x0000c] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Shadows\ShadowRendering.cs:154 at UnityEngine.Rendering.Universal.RendererLighting.RenderLightSet (UnityEngine.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.List1[T] lights) [0x0007e] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Passes\Utility\RendererLighting.cs:265
at UnityEngine.Rendering.Universal.RendererLighting.RenderLights (UnityEngine.Rendering.Universal.IRenderPass2D pass, UnityEngine.Rendering.Universal.RenderingData renderingData, UnityEngine.Rendering.CommandBuffer cmd, System.Int32 layerToRender, UnityEngine.Rendering.Universal.LayerBatch& layerBatch, UnityEngine.RenderTextureDescriptor& rtDesc) [0x00117] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Passes\Utility\RendererLighting.cs:597
at UnityEngine.Rendering.Universal.Render2DLightingPass.DrawLayerBatches (UnityEngine.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) [0x000f6] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Passes\Render2DLightingPass.cs:230
at UnityEngine.Rendering.Universal.Render2DLightingPass.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) [0x00194] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\2D\Passes\Render2DLightingPass.cs:497
at UnityEngine.Rendering.Universal.ScriptableRenderer.ExecuteRenderPass (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.ScriptableRenderPass renderPass, UnityEngine.Rendering.Universal.RenderingData& renderingData) [0x000b8] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\ScriptableRenderer.cs:1581
at 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) [0x00033] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\ScriptableRenderer.cs:1537
at UnityEngine.Rendering.Universal.ScriptableRenderer.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.RenderingData& renderingData) [0x002bd] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\ScriptableRenderer.cs:1320
at UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.Universal.CameraData& cameraData, System.Boolean anyPostProcessingEnabled) [0x002b2] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\UniversalRenderPipeline.cs:714
at UnityEngine.Rendering.Universal.UniversalRenderPipeline.RenderCameraStack (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera baseCamera) [0x003a4] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\UniversalRenderPipeline.cs:878
at UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List1[T] cameras) [0x000da] in .\Library\PackageCache\com.unity.render-pipelines.universal@15.0.6\Runtime\UniversalRenderPipeline.cs:401 at UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List1[T] cameras) [0x0001c] in C:\build\output\unity\unity\Runtime\Export\RenderPipeline\RenderPipeline.cs:52
at UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, UnityEngine.Object renderRequest) [0x00041] in C:\build\output\unity\unity\Runtime\Export\RenderPipeline\RenderPipelineManager.cs:126
(Filename: C:/build/output/unity/unity/Runtime/Export/Graphics/RenderingCommandBuffer.cs Line: 493)
Render Pipeline error : the XR layout still contains active passes. Executing XRSystem.EndLayout() right now.
UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogWarning (object)
UnityEngine.Experimental.Rendering.XRSystem:NewLayout () (at ./Library/PackageCache/com.unity.render-pipelines.core@15.0.6/Runtime/XR/XRSystem.cs:156)
UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderCameraStack (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at ./Library/PackageCache/com.unity.render-pipelines.universal@15.0.6/Runtime/UniversalRenderPipeline.cs:827)
UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List1<UnityEngine.Camera>) (at ./Library/PackageCache/com.unity.render-pipelines.universal@15.0.6/Runtime/UniversalRenderPipeline.cs:401) UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List1<UnityEngine.Camera>) (at C:/build/output/unity/unity/Runtime/Export/RenderPipeline/RenderPipeline.cs:52)
UnityEngine.Rendering.RenderPipelineManager:smile:oRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,UnityEngine.Object) (at C:/build/output/unity/unity/Runtime/Export/RenderPipeline/RenderPipelineManager.cs:126)
(Filename: ./Library/PackageCache/com.unity.render-pipelines.core@15.0.6/Runtime/XR/XRSystem.cs Line: 156)

Neat! Looks like you’re missing a camera with a full-screen clear… this makes each subsequent frame paste in on top of the next. Make sure there are not earlier errors: always start with the first one.

You might try reimporting all, or perhaps just remaking the camera setup you’re using at this point in the game, or try wiggle some settings on it.

Time to start debugging! Here is how you can begin your exciting new debugging adventures:

You must find a way to get the information you need in order to reason about what the problem is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

What is often happening in these cases is one of the following:

  • the code you think is executing is not actually executing at all
  • the code is executing far EARLIER or LATER than you think
  • the code is executing far LESS OFTEN than you think
  • the code is executing far MORE OFTEN than you think
  • the code is executing on another GameObject than you think it is
  • you’re getting an error or warning and you haven’t noticed it in the console window

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run? what order does it run in?
  • what are the names of the GameObjects or Components involved?
  • what are the values of the variables involved? Are they initialized? Are the values reasonable?
  • are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

Knowing this information will help you reason about the behavior you are seeing.

You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as Debug.Log("Problem!",this);

If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

You could also just display various important quantities in UI Text elements to watch them change as you play the game.

Visit Google for how to see console output from builds. If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer for iOS: How To - Capturing Device Logs on iOS or this answer for Android: How To - Capturing Device Logs on Android

If you are working in VR, it might be useful to make your on onscreen log output, or integrate one from the asset store, so you can see what is happening as you operate your software.

Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

If your problem is with OnCollision-type functions, print the name of what is passed in!

Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

“When in doubt, print it out!™” - Kurt Dekker (and many others)

Note: the print() function is an alias for Debug.Log() provided by the MonoBehaviour class.