public static UnityAction <string> AddOnValueChangedActionThrottled(this InputField self, Action <string> onValueChanged, double delayInMs = 500) { EventHandler <string> action = (_, newText) => { onValueChanged(newText); }; var throttledAction = action.AsThrottledDebounce(delayInMs, skipFirstEvent: true); return(self.AddOnValueChangedAction((newText) => { throttledAction(self, newText); return true; })); }
public static void AddOnValueChangedActionThrottled(this InputField self, Action <string> onValueChanged, double delayInMs = 1000) { EventHandler <string> action = (input, newText) => { onValueChanged(newText); }; var throttledAction = action.AsThrottledDebounce(delayInMs); self.AddOnValueChangedAction((newText) => { throttledAction(self, newText); return(true); }); }