Getting NullReferenceException When Building to Android and Using Immediate Mode Drawing
Whenever I load a scene where I am doing Immediate Mode Drawing after building to Android, using
using (Draw.Command(cam))
I get the following runtime error (I have Compatibility Mode disabled.):
2024/12/11 21:31:22.985 24901 25004 Error Unity NullReferenceException: Object reference not set to an instance of an object. 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphResourceRegistry.GetRenderTargetInfo (UnityEngine.Rendering.RenderGraphModule.ResourceHandle& res, UnityEngine.Rendering.RenderGraphModule.RenderTargetInfo& outInfo) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.CheckUseFragment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Boolean isDepth) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at UnityEngine.Rendering.RenderGraphModule.RenderGraphBuilders.SetRenderAttachment (UnityEngine.Rendering.RenderGraphModule.TextureHandle tex, System.Int32 index, UnityEngine.Rendering.RenderGraphModule.AccessFlags flags, System.Int32 mipLevel, System.Int32 depthSlice) [0x00000] in <00000000000000000000000000000000>:0 2024/12/11 21:31:22.985 24901 25004 Error Unity at Shapes.ShapesRenderPass.RecordRenderGraph (UnityEngine.Rendering.RenderGraphModule.RenderGraph renderGraph, UnityEngine.Renderi
If I disable the script that is using immediate mode drawing, the errors disappear.
I keep trying to find out what has gone wrong with Shapes as it's necessary for my game. Today I was at least able to get an error from the adb logs on Quest:
AndroidPlayer "Oculus_Quest 3@ADB:2G0YC6LF6000D1:0" A non-multisampled texture being bound to a multisampled sampler. Disabling in order to avoid undefined behavior. Please enable the bindMS flag on the texture. UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera(ScriptableRenderContext, UniversalCameraData) UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderCameraStack(ScriptableRenderContext, Camera) UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render(ScriptableRenderContext, List`1) UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal(RenderPipelineAsset, IntPtr, Object) [./Runtime/Shaders/ShaderImpl/ShaderTextureProperty.cpp line 496775000]
This error repeats itself every frame.