public Future schedule(float delay, DelayedFunction delayedFunction) { this.delayedCalls.Add(new DelayedCall() { scheduledTime = Time.unscaledTime + delay, function = delayedFunction }); return(this); }
private void OnPointMeasured(TypedChartPoint <float, RoundedRectangleGeometry, LabelGeometry, SkiaSharpDrawingContext> point) { var visual = point.Visual; var delayedFunction = new DelayedFunction(EasingFunctions.BuildCustomElasticOut(1.5f, 0.60f), point, 30f); _ = visual .TransitionateProperties( nameof(visual.Y), nameof(visual.Height)) .WithAnimation(animation => animation .WithDuration(delayedFunction.Speed) .WithEasingFunction(delayedFunction.Function)); }
/// <summary> /// Waits for inspectors to update before executing the given callback method. /// Executes immediately if not in editor. /// </summary> public static void ExecuteWhenSafe(DelayedFunction function) { #if UNITY_EDITOR if (Application.isEditor) { UnityEditor.EditorApplication.delayCall += new UnityEditor.EditorApplication.CallbackFunction(function); } else { function(); } #else function(); #endif }
private void OnStateEvent(JA.IDevice device, JA.State state, bool value) { switch (state) { case JA.State.OnLine: if (value) { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.RadioOpen)); if (muted) { DelayedFunction.DelayedCall("jabra_mute", () => { ignore_next_mute = true; device.SetMicrophoneMute(muted); }, 2500); } } else { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.RadioClosed)); } break; } }
public void OnButtonEvent(object sender, TranslatedButtonInputEventArgs e) { try { var now = DateTime.Now; var button = e.ButtonId; var value = e.Value ?? false; Debug.WriteLine($"Jabra::OnButtonEvent {now}.{now.Millisecond} {button} {value} is muted: {muted}"); //this gets called twice, at least for bluetooth devices for each event, second event does have right mute state microphone muted, with the var diff = DateTime.UtcNow - last_event; last_event = DateTime.UtcNow; if (diff.TotalMilliseconds < 300) { var hash = "" + device.UsbDevicePath + button + value; if (hash == last_event_hash) { Debug.WriteLine("Ignoring dupe event within 300 ms of last"); return; } last_event_hash = hash; } switch (button) { case ButtonId.OffHook: if (value) { if (!hook_enabled) { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Talk)); } hook_enabled = true; } else { if (hook_enabled) { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup)); device.SetHookState(false); } hook_enabled = false; } break; case ButtonId.Mute: if (!ignore_next_mute) //only done on startup event { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.ToggleMute)); } ignore_next_mute = false; break; case ButtonId.Flash: StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Flash)); break; case ButtonId.RejectCall: StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Hangup)); break; case ButtonId.FireAlarm: throw new Exception("WTF"); case ButtonId.Redial: StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.Redial)); break; case ButtonId.Online: if (value) { ignore_next_mute = true; DelayedFunction.DelayedCall("jabra_mute", () => { now = DateTime.Now; Debug.WriteLine($"Jabra Calling SetMicrophoneMuted {now}.{now.Millisecond}: {this.muted} after we come online"); device.SetMicrophoneMuted(!muted); device.SetMicrophoneMuted(muted); }, 2500); } else { StatusChanged(this, new StatusEventArgs(HEADSET_EVENT_TYPE.RadioClosed)); } break; } } catch (Exception) { } }
public DelayedCallBehavior(float time, bool loop, DelayedFunction f) : base(time) { _loop = loop; _function = f; }