12345678910111213141516171819202122232425262728293031 |
- using System;
- using UnityEngine;
- namespace UniRx.Triggers
- {
- [DisallowMultipleComponent]
- public class ObservableFixedUpdateTrigger : ObservableTriggerBase
- {
- Subject<Unit> fixedUpdate;
-
- void FixedUpdate()
- {
- if (fixedUpdate != null) fixedUpdate.OnNext(Unit.Default);
- }
-
- public IObservable<Unit> FixedUpdateAsObservable()
- {
- return fixedUpdate ?? (fixedUpdate = new Subject<Unit>());
- }
- protected override void RaiseOnCompletedOnDestroy()
- {
- if (fixedUpdate != null)
- {
- fixedUpdate.OnCompleted();
- }
- }
- }
- }
|