Skip to content

通过metatable的__index方法返回function调用cs的对象里面的方法报错 #621

@qcbf

Description

@qcbf

xlua

因为这里有个这样的需求, 我在写一个lua工具脚本,
传进来的可以是lua的table 也可以是cs的对象
尝试跟了一下代码 发现在translator.FastGetCSObj(L, 1)方法里面的LuaAPI.xlua_tocsobj_fast(L,index)返回-1了
这是能重现这个bug的示例

local testLuaObjBase = {}
testLuaObjBase.Value = nil
function testLuaObjBase:__index(key)
    return self.Value[key]
end
local testLuaObj = setmetatable({}, testLuaObjBase)

local tmp = {}
function tmp:Func(name)
    print("func>>>>>>>>>>>>>>>>>>>>", name)
end
testLuaObj.Value = tmp
testLuaObj:Func("TestLuaCall")

testLuaObj.Value = CS.UnityEngine.GameObject.Find("Game")
print(testLuaObj.SetActive)
testLuaObj:SetActive(false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions