diff --git a/Runtime/RuntimeApi.cs b/Runtime/RuntimeApi.cs
index d2c81aa..8169063 100644
--- a/Runtime/RuntimeApi.cs
+++ b/Runtime/RuntimeApi.cs
@@ -11,11 +11,6 @@ namespace HybridCLR
{
public static class RuntimeApi
{
-#if UNITY_EDITOR
- private static int s_interpreterThreadObjectStackSize = 128 * 1024;
- private static int s_interpreterThreadFrameStackSize = 2 * 1024;
-#endif
-
///
/// 加载补充元数据assembly
///
@@ -36,55 +31,65 @@ namespace HybridCLR
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
///
///
-#if UNITY_EDITOR
public static int GetInterpreterThreadObjectStackSize()
{
- return s_interpreterThreadObjectStackSize;
+ return GetRuntimeOption(RuntimeOptionId.InterpreterThreadObjectStackSize);
}
-#else
- [MethodImpl(MethodImplOptions.InternalCall)]
- public static extern int GetInterpreterThreadObjectStackSize();
-#endif
///
/// 设置解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
///
///
-#if UNITY_EDITOR
public static void SetInterpreterThreadObjectStackSize(int size)
{
- s_interpreterThreadObjectStackSize = size;
+ SetRuntimeOption(RuntimeOptionId.InterpreterThreadObjectStackSize, size);
}
-#else
- [MethodImpl(MethodImplOptions.InternalCall)]
- public static extern void SetInterpreterThreadObjectStackSize(int size);
-#endif
+
+
///
/// 获取解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
///
///
-#if UNITY_EDITOR
public static int GetInterpreterThreadFrameStackSize()
{
- return s_interpreterThreadFrameStackSize;
+ return GetRuntimeOption(RuntimeOptionId.InterpreterThreadFrameStackSize);
}
-#else
- [MethodImpl(MethodImplOptions.InternalCall)]
- public static extern int GetInterpreterThreadFrameStackSize();
-#endif
-
+
///
/// 设置解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
///
///
-#if UNITY_EDITOR
public static void SetInterpreterThreadFrameStackSize(int size)
{
- s_interpreterThreadFrameStackSize = size;
+ SetRuntimeOption(RuntimeOptionId.InterpreterThreadFrameStackSize, size);
+ }
+
+
+#if UNITY_EDITOR
+
+ private static readonly Dictionary s_runtimeOptions = new Dictionary();
+
+ public static void SetRuntimeOption(RuntimeOptionId optionId, int value)
+ {
+ s_runtimeOptions[optionId] = value;
}
#else
[MethodImpl(MethodImplOptions.InternalCall)]
- public static extern void SetInterpreterThreadFrameStackSize(int size);
+ public static extern void SetRuntimeOption(RuntimeOptionId optionId, int value);
+#endif
+
+#if UNITY_EDITOR
+ public static int GetRuntimeOption(RuntimeOptionId optionId)
+ {
+ if (s_runtimeOptions.TryGetValue(optionId, out var value))
+ {
+ return value;
+ }
+ return 0;
+ }
+#else
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ public static extern int GetRuntimeOption(RuntimeOptionId optionId);
#endif
}
}
diff --git a/Runtime/RuntimeOptionId.cs b/Runtime/RuntimeOptionId.cs
new file mode 100644
index 0000000..3dc24dc
--- /dev/null
+++ b/Runtime/RuntimeOptionId.cs
@@ -0,0 +1,9 @@
+namespace HybridCLR
+{
+ public enum RuntimeOptionId
+ {
+ InterpreterThreadObjectStackSize = 1,
+ InterpreterThreadFrameStackSize = 2,
+ ThreadExceptionFlowSize = 3,
+ }
+}
diff --git a/Runtime/RuntimeOptionId.cs.meta b/Runtime/RuntimeOptionId.cs.meta
new file mode 100644
index 0000000..9c7181e
--- /dev/null
+++ b/Runtime/RuntimeOptionId.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 64be598b47302644a96013c74d945653
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: