local Ex03_BindDelegates = UnLua.Class() function Ex03_BindDelegates.Construct(self) self.clickCount = 0 self.timerTickCount = 0 if self.ClickMeButton ~= nil then self.ClickMeButton.OnClicked:Add(self, self.OnButtonClicked) end if self.CustomSingleDelegate ~= nil then self.CustomSingleDelegate:Bind(self, self.OnCustomExecute) end self.timerHandle = UE.UKismetSystemLibrary.K2_SetTimerDelegate({self, self.OnTimerTick}, 0.5, true) end function Ex03_BindDelegates.OnButtonClicked(self) self.clickCount = self.clickCount + 1 end function Ex03_BindDelegates.OnCustomExecute(self, value) return value * 10 + self.clickCount end function Ex03_BindDelegates.OnTimerTick(self) if not UE.UKismetSystemLibrary.IsValid(self) then return end self.timerTickCount = self.timerTickCount + 1 end function Ex03_BindDelegates.Destruct(self) if self.ClickMeButton ~= nil then self.ClickMeButton.OnClicked:Remove(self, self.OnButtonClicked) end if self.CustomSingleDelegate ~= nil then self.CustomSingleDelegate:Unbind() end UE.UKismetSystemLibrary.K2_ClearAndInvalidateTimerHandle(self, self.timerHandle) end function Ex03_BindDelegates.GetClickCount(self) return self.clickCount end function Ex03_BindDelegates.GetTimerTickCount(self) return self.timerTickCount end function Ex03_BindDelegates.GetTimerHandle(self) return self.timerHandle end return Ex03_BindDelegates