using System; // require keep for Windows Universal App using UnityEngine; namespace UniRx.Triggers { [DisallowMultipleComponent] public class ObservableFixedUpdateTrigger : ObservableTriggerBase { Subject fixedUpdate; /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. void FixedUpdate() { if (fixedUpdate != null) fixedUpdate.OnNext(Unit.Default); } /// This function is called every fixed framerate frame, if the MonoBehaviour is enabled. public IObservable FixedUpdateAsObservable() { return fixedUpdate ?? (fixedUpdate = new Subject()); } protected override void RaiseOnCompletedOnDestroy() { if (fixedUpdate != null) { fixedUpdate.OnCompleted(); } } } }