That’s because in a built game safety checks are disabled, so in the editor the safety check is throwing that error and in the game you are just flat out violating the bounds and causing a hard crash.
Is it possible to make a build with safety checks enabled? At least during testing (and on Steam beta branch).
From il2cpp:
If that’s the same case in ecs and it’s disabled by default then it’s getting problematic. My game was crashing in weird places like AudioSettings.Reset().
Not sure if it matters but that entityManager.SetComponentData is called from main thread in MonoBehaviour - burst/systems not used in that case.
Well I’m not sure, there were few issues. I fixed all that could be found in the editor. I guess I’ll make my own length check with defines for testing builds:
#if NATIVE_ARR_LEN_CHECK
if( i >= nativeArray.Length )
Debug.LogError( $"{i} of {nameof(nativeArray)} is out of range");
#endif
nativeArray[i] = ...
Extension method would be cleaner but probably very slow with how il2cpp handles them.