Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

阿楠,C#传递到lua的lightuserdata没有metadata,没法还原成class,我hack了你的代码,你看这样好不好 #48

Open
allan163 opened this issue Nov 4, 2014 · 0 comments

Comments

@allan163
Copy link

allan163 commented Nov 4, 2014

如果我要用Unilua操作在Scence中已有的对象,就必须把对象传给Unilua。比如我在scene中有个GameObject a, 那么我用Lua.PushLightUserData(a)把东西push到lua里。
lua 函数是这样:
local function DisableButton(a)
a:SetActive(false)
end
这样是不行的,因为a只是一个LightUserData,实际上是一块内存,没有了GameObject的field和method了。而ffi.lua中没有把new_class_mgr暴露出来,造成虽然我可以创建新的Gameobject,但是没法从内存中还原Gameobject。
看了代码后我在resolve_builder()中加了一行
mod.cls_mgr = cls_mgr
把new_class_mgr暴露了出来,才能使用
obj = UnityEngine.cls_mgr.make_instance('GameObject', a)
这样比较丑陋,但是实现了我想要的功能。
请问还有更好的办法吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant