Description
When true, array bounds are actively validated in code generated by IL2CPP. When false, they are not.
This setting is only supported for some closed platforms. On those platforms it's a configurable option in the platform build profile, and more information is available in the relevant platform-specific documentation.
Important:
- It's strongly recommended to keep array bounds checks on. Turning them off can improve runtime performance but allows code to access an array with invalid indices, which can lead to incorrect behavior, including reading from or writing to arbitrary memory locations. In most cases, these memory accesses occur without any immediate side effects, and can corrupt the state of the application with no obvious warning signs, making the errors hard to debug. If you choose to turn array bounds checks off, you must ensure that no out-of-bounds access occurs in the affected code.
- On the platforms that support this setting, it applies globally to all C# code. It's recommended to use the
[Il2CppSetOption] attribute instead, which is supported on all platfoms and allows you to apply the equivalent behavior more restrictively to specific methods, classes, or assemblies. For more information, refer to IL2CPP runtime code checks in the Unity manual.