NullRef exception only on android devices when using Draw.Text()
I traced it but I'm still at a loss, especially since this was working earlier.
2024/12/04 21:05:33.818 15332 15361 Info Unity System.NullReferenceException: Object reference not set to an instance of an object.
2024/12/04 21:05:33.818 15332 15361 Info Unity at UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at UnityEngine.Material.get_shader () [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at Shapes.IMDrawer..ctor (Shapes.MetaMpb metaMpb, UnityEngine.Material sourceMat, UnityEngine.Mesh sourceMesh, System.Int32 submesh, Shapes.IMDrawer+DrawType drawType, System.Boolean allowInstancing, System.Int32 textAutoDisposeId) [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at Shapes.Draw.Text_Internal (TMPro.TextMeshPro tmp, Shapes.IMDrawer+DrawType drawType, System.Int32 disposeId) [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at Sunsear.Game.ShmupBoss.SfxSource..ctor () [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at Sunsear.Game.UI.StageHUD.DrawShapes (UnityEngine.Camera cam) [0x00000] in <00000000000000000000000000000000>:0
2024/12/04 21:05:33.818 15332 15361 Info Unity at UnityEngine.Rendering.Universal.Universa
Notably, when I uncomment the #if UNITY_EDITOR code, this appears in logcat:
Input material is null :(
But this doesn't happen when running the game in the editor. For my code, I first run
timer = new TextElement();
and then in DrawShapes, I call
Draw.Text(timer, new Vector3(Screen.safeArea.width * 0.5f, Screen.safeArea.height - 100, 0), Quaternion.identity, TimerText, TextAlign.Center, 1000, timerFontAsset);
Any idea how to work around this? I don't know what Material it needs because the TMP Font asset already has a material assigned =/
Reporting a bug? please specify Unity version:
6000.0.23
Reporting a bug? please specify Shapes version:
4.5.0
Reporting a bug? please specify Render Pipeline:
URP