zoukankan      html  css  js  c++  java
  • 从C#中传递object到lua的一个问题

    本来我是想从C#中把form对象传递到Lua里面去,然后在Lua中调用form下面的各个组件,比如textbox、button等,从而实现在Lua中控制C#中form界面的布局。

    但是发现如下问题:

     1 //Form1.cs
    2
    3 class Form1
    4 {
    5 private System.Windows.Forms.TextBox textBox1;
    6 private System.Windows.Forms.Button button1;
    7
    8 private void button1_Click(object sender, EventArgs e)
    9 {
    10 Lua m_lua = new Lua();
    11 m_lua.DoFile("plugin.lua");
    12 object[] objs = m_lua.GetFunction("OnLoad").Call(this, this.textBox1);
    13 m_lua.Close();
    14 }
    15 }
    1 --plugin.lua
    2
    3 function OnLoad(form, textbox)
    4 textbox.Text = form.button1.Text -->Nil
    5 textbox.Text = form.button1 -->希望获得button对象,结果发现这个是字符串
    6 end


    问题在于,本来我以为将form传递到lua中后,就可以在lua中调用form.button1及对象链,结果发现form.button1变成了字符串。

    我猜测可能是只能传递单个对象,其属性和下属的子对象只能变成string了(toString())。

  • 相关阅读:
    安卓状态栏适配暗黑模式
    HtmlUnit框架:新建窗口与在新窗口打开链接
    Kotlin/Java下载文件(基于HttpClient Fluent API)
    导出可执行jar包
    Kotlin协程重要概念介绍
    MyBatis学习笔记
    执行上下文
    axios封装
    基础类型
    css特效基础
  • 原文地址:https://www.cnblogs.com/ifan/p/2282573.html
Copyright © 2011-2022 走看看