-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInjectorCSharp.cs
45 lines (36 loc) · 1004 Bytes
/
InjectorCSharp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#if UNITY_EDITOR
using ChenPipi.CodeExecutor.Editor;
using UnityEditor;
using UnityEngine;
namespace ChenPipi.CodeExecutor.Examples
{
/// <summary>
/// 给 CodeExecutor 注入代码执行模式
/// </summary>
public static class InjectorCSharp
{
/// <summary>
/// 注册 CodeExecutor 执行模式
/// </summary>
[CodeExecutorRegistration(0)]
private static void Register()
{
if (!CodeExecutorSettings.enableBuiltinExecModeCSharp)
{
return;
}
CodeExecutorManager.RegisterExecMode(new ExecutionMode
{
name = "C#",
executor = Executor,
});
}
public static object[] Executor(string code)
{
object[] results = ExecutionHelperCSharp.ExecuteSnippetCode(code);
CodeExecutorManager.ShowNotification("Executed");
return results;
}
}
}
#endif