From 05d5a18b8905774541e31a8ee3da491ff6bbfbc7 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 1 May 2024 14:47:52 +0800 Subject: [PATCH] add il2cpp options --- src/ThreadRunner.cs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/ThreadRunner.cs b/src/ThreadRunner.cs index 01f5e39..88883c6 100644 --- a/src/ThreadRunner.cs +++ b/src/ThreadRunner.cs @@ -5,6 +5,11 @@ using System.Threading; namespace DCFApixels.DragonECS { +#if ENABLE_IL2CPP + using Unity.IL2CPP.CompilerServices; + [Il2CppSetOption (Option.NullChecks, false)] + [Il2CppSetOption(Option.ArrayBoundsChecks, false)] +#endif internal static class ThreadRunner { private readonly static int _maxThreadsCount; @@ -146,4 +151,34 @@ namespace DCFApixels.DragonECS } } public delegate void EcsThreadHandler(ReadOnlySpan entities); -} \ No newline at end of file +} + + + + + + +#if ENABLE_IL2CPP +// Unity IL2CPP performance optimization attribute. +namespace Unity.IL2CPP.CompilerServices +{ + using System; + internal enum Option + { + NullChecks = 1, + ArrayBoundsChecks = 2, + DivideByZeroChecks = 3, + } + [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate, Inherited = false, AllowMultiple = true)] + internal class Il2CppSetOptionAttribute : Attribute + { + public Option Option { get; private set; } + public object Value { get; private set; } + public Il2CppSetOptionAttribute(Option option, object value) + { + Option = option; + Value = value; + } + } +} +#endif \ No newline at end of file