xlua修复子类中未实现的父类函数

发布时间 2023-12-22 11:51:53作者: mc宇少
xlua.hotfix(ClsType, "Method", function(self, a, b)
    if type(a) == "userdata" then
        if a:GetType() == CS.A.UnderlyingSystemType then
            print("A hotfix")
        elseif a:GetType() == CS.B.UnderlyingSystemType then
            print("B hotfix")
        end
    elseif type(a) == "number" then
        print(a + b)
    elseif type(a) == "string" then
        print(a..b)
    else
        base(self):Func()
    end
end)

 直接修复父类的函数、并在父类的函数中判断类型来执行相应的操作。