美文网首页unity3D技术分享
unity lua table存储function,进行批量处理

unity lua table存储function,进行批量处理

作者: 好怕怕 | 来源:发表于2020-11-14 10:25 被阅读0次
local type = {a=1, b=2}

function aEnter() 
    print("aEnter")
end

function aExit() 
    print("aExit")
end

function bEnter(num) 
    print("bEnter:"..num)
end

function bExit() 
    print("bExit")
end

local func = 
{
    [type.a] = { Enter = aEnter, Exit = aExit },
    [type.b] = { Enter = bEnter, Exit = bExit },
}
print( func[type.a].Enter())
print( func[type.b].Enter(101))

相关文章

网友评论

    本文标题:unity lua table存储function,进行批量处理

    本文链接:https://www.haomeiwen.com/subject/puiibktx.html