本文整理汇总了C#中NLua.Lua.RegisterLuaDelegateType方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.RegisterLuaDelegateType方法的具体用法?C# Lua.RegisterLuaDelegateType怎么用?C# Lua.RegisterLuaDelegateType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NLua.Lua
的用法示例。
在下文中一共展示了Lua.RegisterLuaDelegateType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterNLuaBox
public static void RegisterNLuaBox(Lua context)
{
context.RegisterLuaDelegateType (typeof (EventHandler<EventArgs>), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler<UIButtonEventArgs>), typeof (LuaButtonEventArgsHandler));
context.RegisterLuaClassType (typeof (UIViewController), typeof (NLuaBoxUIViewControllerBinder));
}
示例2: RegisterNLuaBox
public static void RegisterNLuaBox(Lua context)
{
context.RegisterLuaDelegateType (typeof (EventHandler<EventArgs>), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler), typeof (LuaEventArgsHandler));
context.RegisterLuaDelegateType (typeof (EventHandler<UIButtonEventArgs>), typeof (LuaButtonEventArgsHandler));
context.RegisterLuaDelegateType (typeof(NSAction), typeof(LuaNSActionHandler));
context.RegisterLuaClassType (typeof (UIViewController), typeof (NLuaBoxUIViewControllerBinder));
context.RegisterLuaClassType (typeof (UITableViewSource), typeof (NLuaBoxUITableViewSourceBinder));
context.RegisterLuaClassType (typeof (JLTextViewController), typeof (NLuaBoxDetailLuaViewController));
context.RegisterLuaClassType (typeof (DialogViewController), typeof (NLuaBoxDialogViewControllerBinder));
context.RegisterLuaClassType (typeof (UITableViewController), typeof (NLuaBoxUITableViewControllerBinder));
context.RegisterFunction ("CreateListString", typeof (NLuaBoxBinder).GetMethod ("CreateListString"));
}
示例3: RegisterNLuaDelegate
public static void RegisterNLuaDelegate(Lua context)
{
//Only For IOS
context.RegisterLuaDelegateType(typeof(EventTriggerListener.VoidDelegate), typeof(CallbackLuaFunction<GameObject>));
context.RegisterLuaDelegateType(typeof(Action<object>), typeof(CallbackLuaFunction<object>));
context.RegisterLuaDelegateType(typeof(Action), typeof(CallbackLuaFunction));
context.RegisterLuaDelegateType(typeof(Callback), typeof(CallbackLuaFunction));
context.RegisterLuaDelegateType(typeof(Callback<object>), typeof(CallbackLuaFunction<object>));
context.RegisterLuaDelegateType(typeof(Callback<string, AssetBundle>), typeof(CallbackLuaFunction<string, AssetBundle>));
}
示例4: TestEventException
public void TestEventException ()
{
using (Lua lua = new Lua ()) {
//Register a C# function
MethodInfo testException = this.GetType ().GetMethod ("_TestException", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance, null, new Type [] {
typeof(float),
typeof(float)
}, null);
lua.RegisterFunction ("Multiply", this, testException);
lua.RegisterLuaDelegateType (typeof(EventHandler<EventArgs>), typeof(LuaEventArgsHandler));
//create the lua event handler code for the entity
//includes the bad code!
lua.DoString ("function OnClick(sender, eventArgs)\r\n" +
"--Multiply expects 2 floats, but instead receives 2 strings\r\n" +
"Multiply(asd, es)\r\n" +
"end");
//create the lua event handler code for the entity
//good code
//lua.DoString("function OnClick(sender, eventArgs)\r\n" +
// "--Multiply expects 2 floats\r\n" +
// "Multiply(2, 50)\r\n" +
// "end");
//Create the event handler script
lua.DoString ("function SubscribeEntity(e)\r\ne.Clicked:Add(OnClick)\r\nend");
//Create the entity object
Entity entity = new Entity ();
//Register the entity object with the event handler inside lua
LuaFunction lf = lua.GetFunction ("SubscribeEntity");
lf.Call (new object [1] { entity });
try {
//Cause the event to be fired
entity.Click ();
//failed
Assert.AreEqual(true, false);
} catch (LuaException) {
//passed
Assert.AreEqual (true, true);
}
}
}
示例5: LuaDelegateReferenceTypesByRefParam
public void LuaDelegateReferenceTypesByRefParam ()
{
using (Lua lua = new Lua ()) {
lua.RegisterLuaDelegateType (typeof(TestDelegate7), typeof(LuaTestDelegate7Handler));
lua.DoString ("luanet.load_assembly('NLuaTest')");
lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
lua.DoString ("test=TestClass()");
lua.DoString ("function func(x,y) return TestClass(x+y.testval); end");
lua.DoString ("a=test:callDelegate7(func)");
int a = (int)lua.GetNumber ("a");
Assert.AreEqual (5, a);
//Console.WriteLine("delegate returned: "+a);
}
}
示例6: LuaDelegateValueTypesOutParam
public void LuaDelegateValueTypesOutParam ()
{
using (Lua lua = new Lua ()) {
lua.RegisterLuaDelegateType (typeof(TestDelegate2), typeof(LuaTestDelegate2Handler));
lua.DoString ("luanet.load_assembly('NLuaTest')");
lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
lua.DoString ("test=TestClass()");
lua.DoString ("function func(x) return x,x*2; end");
lua.DoString ("test=TestClass()");
lua.DoString ("a=test:callDelegate2(func)");
int a = (int)lua.GetNumber ("a");
Assert.AreEqual (6, a);
//Console.WriteLine("delegate returned: "+a);
}
}
示例7: RegisterNLuaDelegate
public static void RegisterNLuaDelegate(Lua context)
{
//主要针对ios,aot下不能有动态模板映射,当kera模式在ios发布平台的时候
context.RegisterLuaDelegateType(typeof(EventListener.VoidDelegate), typeof(CallbackLuaFunction<GameObject>));
context.RegisterLuaDelegateType(typeof(Action<object>), typeof(CallbackLuaFunction<object>));
context.RegisterLuaDelegateType(typeof(Action), typeof(CallbackLuaFunction));
context.RegisterLuaDelegateType(typeof(Callback), typeof(CallbackLuaFunction));
context.RegisterLuaDelegateType(typeof(Callback<object>), typeof(CallbackLuaFunction<object>));
context.RegisterLuaDelegateType(typeof(Callback<string, AssetBundle>), typeof(CallbackLuaFunction<string, AssetBundle>));
context.RegisterLuaDelegateType(typeof(DownloadProgressChangedEventHandler), typeof(CallbackLuaFunction<object, DownloadProgressChangedEventArgs>));
context.RegisterLuaDelegateType(typeof(AsyncCompletedEventHandler), typeof(CallbackLuaFunction<object, AsyncCompletedEventArgs>));
context.RegisterLuaDelegateType(typeof(UploadProgressChangedEventHandler), typeof(CallbackLuaFunction<object, UploadProgressChangedEventArgs>));
context.RegisterLuaDelegateType(typeof(UploadStringCompletedEventHandler), typeof(CallbackLuaFunction<object, UploadStringCompletedEventArgs>));
}