private void CompositionTarget_Rendering(object sender, EventArgs e) { var delta = DateTime.Now - Started; if (delta >= Duration) { if (Loop) { Started = DateTime.Now; } else { System.Windows.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering; Animator(1); IsAnimating = false; } CompletedAction?.Invoke(); Completed?.Invoke(this, new EventArgs()); } else { Animator(delta.TotalMilliseconds / Duration.TotalMilliseconds); } }
public void Stop() { System.Windows.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering; if (IsAnimating) { CompletedAction?.Invoke(); Completed?.Invoke(this, new EventArgs()); IsAnimating = false; } }
void ProcessAction(GameObject obj, CompletedAction choice) { switch (choice) { case CompletedAction.ENABLE: obj.SetActive(true); break; case CompletedAction.DISABLE: obj.SetActive(false); break; } }