using System; #if UniRxLibrary using UnityObservable = UniRx.ObservableUnity; #else using UnityObservable = UniRx.Observable; #endif namespace UniRx.Operators { internal class DelayFrameSubscriptionObservable : OperatorObservableBase { readonly IObservable source; readonly int frameCount; readonly FrameCountType frameCountType; public DelayFrameSubscriptionObservable(IObservable source, int frameCount, FrameCountType frameCountType) : base(source.IsRequiredSubscribeOnCurrentThread()) { this.source = source; this.frameCount = frameCount; this.frameCountType = frameCountType; } protected override IDisposable SubscribeCore(IObserver observer, IDisposable cancel) { var d = new MultipleAssignmentDisposable(); d.Disposable = UnityObservable.TimerFrame(frameCount, frameCountType) .SubscribeWithState3(observer, d, source, (_, o, disp, s) => { disp.Disposable = s.Subscribe(o); }); return d; } } }