-
Notifications
You must be signed in to change notification settings - Fork 9
/
Example101.cs
57 lines (51 loc) · 1.07 KB
/
Example101.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
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using Puerts;
using XLua;
/// <summary>
/// 调用脚本function
/// 逻辑: 无
/// 参数: 无
/// 返回值: 无
/// </summary>
[Test(100)]
public class Example101 : IExecute
{
[CSharpCallLua]
public delegate void TargetFunc();
[CSharpCallLua]
public delegate TargetFunc CreateFunc();
public bool Static => true;
public string Method => "payload(): void;";
public CallTarget Target => CallTarget.CSharpCallScript;
public object RunCS(int count)
{
throw new System.NotImplementedException();
}
public object RunJS(JsEnv env, int count)
{
var func = env.Eval<TargetFunc>(@"
function payload(){
}
payload;
");
for (int i = 0; i < count; i++)
{
func();
}
return null;
}
public object RunLua(LuaEnv env, int count)
{
var create = env.LoadString<CreateFunc>(@"
local function payload()
end
return payload;
");
var func = create();
for (int i = 0; i < count; i++)
{
func();
}
return null;
}
}