I have also had the same problem and I have been able to fix it 🙂
The bug was exactly at this line:
drawOrder[originalIndex + (int)(float)offsetMap["offset"]] = originalIndex++;
Since IL2CPP generates C++ files out of the C# IL-Code, there is some magic happening in the process. The outcome of that was that the originalIndex variable was being incremented before accessing to the array element.
This is the generated c++ for that piece of code:
NullCheck(V_59);
Object_t * L_142 = (Object_t *)VirtFuncInvoker1< Object_t *, String_t* >::Invoke(Dictionary_2_get_Item_m20848_MethodInfo_var, V_59, (String_t*) &_stringLiteral4643);
int32_t L_143 = V_57;
V_57 = ((int32_t)((int32_t)L_143+(int32_t)1));
NullCheck(V_53);
IL2CPP_ARRAY_BOUNDS_CHECK(V_53, ((int32_t)((int32_t)V_57+(int32_t)(((int32_t)(([i](float[/i])((float*)UnBox (L_142, InitializedTypeInfo(&Single_t80_il2cpp_TypeInfo))))))))));
[i]((int32_t[/i])(int32_t*)SZArrayLdElema(V_53, ((int32_t)((int32_t)V_57+(int32_t)(((int32_t)(([i](float[/i])((float*)UnBox (L_142, InitializedTypeInfo(&Single_t80_il2cpp_TypeInfo))))))))))) = (int32_t)L_143;
That code uses an "off by 1" index when accessing the array.
I changed that line to:
drawOrder[originalIndex + (int)(float)offsetMap["offset"]] = originalIndex+1;
originalIndex++;
which, in IL2CPP code is:
NullCheck(V_59);
Object_t * L_142 = (Object_t *)VirtFuncInvoker1< Object_t *, String_t* >::Invoke(Dictionary_2_get_Item_m20848_MethodInfo_var, V_59, (String_t*) &_stringLiteral4643);
NullCheck(V_53);
IL2CPP_ARRAY_BOUNDS_CHECK(V_53, ((int32_t)((int32_t)V_57+(int32_t)(((int32_t)(([i](float[/i])((float*)UnBox (L_142, InitializedTypeInfo(&Single_t80_il2cpp_TypeInfo))))))))));
[i]((int32_t[/i])(int32_t*)SZArrayLdElema(V_53, ((int32_t)((int32_t)V_57+(int32_t)(((int32_t)(([i](float[/i])((float*)UnBox (L_142, InitializedTypeInfo(&Single_t80_il2cpp_TypeInfo))))))))))) = (int32_t)((int32_t)((int32_t)V_57+(int32_t)1));
V_57 = ((int32_t)((int32_t)V_57+(int32_t)1));
And now it's all good :rofl: