I’ve been receiving an IndexOutOfRange exception in the following code in Awake() in the TMPro class from the title:
TMP_SubMeshUI[] subTextObjects = GetComponentsInChildren<TMP_SubMeshUI>();
if (subTextObjects.Length > 0)
{
for (int i = 0; i < subTextObjects.Length; i++)
m_subTextObjects[i + 1] = subTextObjects[i];
}
It’s around line 137 in v2.0.1.
The problem is that m_subTextObjects
is declared as:
protected TMP_SubMeshUI[] m_subTextObjects = new TMP_SubMeshUI[8];
but the size of subTextObjects is 8, so it ALWAYS overflows the array.
“Fixing” it by declaring m_subTextObjects to hold 9 elements works, but I don’t know why this off-by-one is there in the first place.