_G.UIFather = {} function UIFather:New(prefab) local t = { ["prefab"] = prefab } setmetatable(t, self) self.__index = self return t end function UIFather:RegisterCloseEvent(instance, func, ...) function UIFather:OnEvent(event,param) end end function UIFather:OnEnable(instance) end function UIFather:OnDisable(instance) end _G.A = _G.UIFather:New() print("母函数调用之前" ,A["OnEnable"], A["OnEvent"],UIFather["OnEvent"]) UIFather:RegisterCloseEvent() print("母函数调用之后" ,A["OnEnable"], A["OnEvent"],UIFather["OnEvent"])
调用结果为:
母函数调用之前 function: 0054CDF0 nil nil 母函数调用之后 function: 0054CDF0 function: 0054CE70 function: 0054CE70 [Finished in 0.1s]