I encounter a Null Reference Exception when loading an asset bundle containing 3D TextMeshPro texts. The asset bundles with the 3D TextMeshPro texts were built using Unity version 2022.3.X. This issue arises specifically when targeting Android and iOS apps built from Unity version 6000.0.32f1.
Here are the logs from the exception:
2024-11-20 13:04:47.579 15345 15427 Error Unity NullReferenceException: Object reference not set to an instance of an object.
2024-11-20 13:04:47.579 15345 15427 Error Unity at TMPro.MaterialReference..ctor (System.Int32 index, TMPro.TMP_FontAsset fontAsset, TMPro.TMP_SpriteAsset spriteAsset, UnityEngine.Material material, System.Single padding) [0x00000] in <00000000000000000000000000000000>:0
2024-11-20 13:04:47.579 15345 15427 Error Unity at TMPro.TextMeshPro.SetArraySizes (TMPro.TMP_Text+TextProcessingElement[] textProcessingArray) [0x00000] in <00000000000000000000000000000000>:0
2024-11-20 13:04:47.579 15345 15427 Error Unity at TMPro.TextMeshPro.OnPreRenderObject () [0x00000] in <00000000000000000000000000000000>:0
2024-11-20 13:04:47.579 15345 15427 Error Unity at TMPro.TextMeshPro.Rebuild (UnityEngine.UI.CanvasUpdate update) [0x00000] in <00000000000000000000000000000000>:0
2024-11-20 13:04:47.579 15345 15427 Error Unity at TMPro.TMP_UpdateManager.DoRebuilds () [0x00000] in <00000000000000000000000000000000>:0
This error suggests that there might be an issue with initializing the TextMeshPro components or their dependencies when loading from the asset bundle.
Please Note:
- I want to avoid rebuilding the asset bundles with Unity 6000.X as there are thousands of asset bundles with different font styles.
- We have successfully upgraded our entire project from 2022.X to 6000.0.X and everything else seems to be working fine. Also, the overall performance improvements are palpable in all scenes. So the bottom line is that we want to upgrade to Unity 6 from 2022.X and hence please avoid the suggestions of sticking to the older version of Unity for our app builds.
@Stephan_B, Could you please help me with some insights on how to work around this issue?
If anyone else has experienced a similar issue or has insights into potential workarounds or fixes, I would greatly appreciate your help!
Thank you!