GithubHelp home page GithubHelp logo

lua 调用 c# delegate 报错 about xlua HOT 6 CLOSED

wulei avatar wulei commented on May 12, 2024
lua 调用 c# delegate 报错

from xlua.

Comments (6)

chexiongsheng avatar chexiongsheng commented on May 12, 2024 2

你要先判空,空的话直接OnOpen=function。
貌似c#下也是会报错的吧,如果左值为null的话

from xlua.

Jayatubi avatar Jayatubi commented on May 12, 2024

delegate可以用'+'么?我以为只有event可以那样写。

from xlua.

chexiongsheng avatar chexiongsheng commented on May 12, 2024

ws.OnOpen = ws.OnOpen + function() end

另外,你那个delegate要加CSharpCallLua

from xlua.

chexiongsheng avatar chexiongsheng commented on May 12, 2024

其实在教程都有,最好去看看

from xlua.

wulei avatar wulei commented on May 12, 2024

不好意思,教程里面我看歪了。
把delegate的+链接和event混了。

from xlua.

wulei avatar wulei commented on May 12, 2024

@chexiongsheng

LuaException: [string "WebsocketTest.lua"]:24: attempt to perform arithmetic on a nil value (field 'OnClosed')
stack traceback:
	[string "WebsocketTest.lua"]:24: in function <[string "WebsocketTest.lua"]:10>
XLua.LuaEnv.ThrowExceptionFromError (Int32 oldTop) (at Assets/xLua/Src/LuaEnv.cs:360)
XLuaGenDelegateImpl0.Invoke2 ()
LuaBehaviour.Start () (at Assets/_LFramework/Scripts/Common/LuaBehaviour.cs:70)

教程里面中的是ok的,但是这个是说 on a nil value,已经在delegate中加入CSharpCallLua,而且我调用ws.IsOpen的bool值不会有问题

from xlua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.