Hello
Could I request clarification or modification?
I have a setup that I can’t quite get to the bottom of a problem. I have a gameobject with a canvas and two input fields. Part of a larger project but those are the elements that cause me the issue.
I set the gameobject as inactive, but I till occasionally get the following error
(Filename: currently not available on il2cpp Line: -1)
2020-07-27 16:59:10.266 23066-23081/xxx.xxxx.xxxt E/Unity: NullReferenceException: Object reference not set to an instance of an object.
at TMPro.TMP_InputField.GenerateCaret (UnityEngine.UI.VertexHelper vbo, UnityEngine.Vector2 roundingOffset) [0x00000] in <00000000000000000000000000000000>:0
at TMPro.TMP_InputField.OnFillVBO (UnityEngine.Mesh vbo) [0x00000] in <00000000000000000000000000000000>:0
at TMPro.TMP_InputField.UpdateGeometry () [0x00000] in <00000000000000000000000000000000>:0
at TMPro.TMP_InputField.Rebuild (UnityEngine.UI.CanvasUpdate update) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Canvas+WillRenderCanvases.Invoke () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.UI.CanvasUpdateRegistry:PerformUpdate()
UnityEngine.WillRenderCanvases:Invoke()
I can get rid of the exception by adding the following to the top of GenerateCaret
if (m_CaretVisible == false || m_TextComponent.canvas == null)
return;
Once the error starts it won’t stop and then causes a performance issue on the Android-based VR device.
Even if I mark the canvas as not enabled I still get the issue. Unity seems to still want to Render the Canvas even though it is not enabled.
It is however excruciatingly difficult to pin down the exact cause. I want to think its a timing issue in terms of when the canvas is marked as not enabled.
Has anyone come across something similar and if not could I request that a check for m_TextComponent.canvas == null be a permanent addition to GenerateCaret.