2025-01-04 23:00:19 +08:00

37 lines
746 B
Lua

--[[
[使用方法]
====初始化====
local UGCDelegate = require("Script.Common.UGCDelegate");
local DelObj = UGCDelegate.New(self, self.SomeFunction);
====在需要调用的地方====
DelObj:Execute(Par1, Par2, Par3);
--]]
---@class UGCDelegate
local UGCDelegate = LuaClass("UGCDelegate");
UGCDelegate.Object = nil;
UGCDelegate.Func = nil;
--- 构造函数
---@param InObject any
---@param InFunc function @函数变量
function UGCDelegate:ctor(InObject, InFunc)
self.Object = InObject;
self.Func = InFunc;
end
--- 调用回调函数
function UGCDelegate:Execute(...)
if self.Object ~= nil then
self.Func(self.Object, ...);
elseif self.Func ~= nil then
self.Func(...);
end
end
return UGCDelegate;