コード例 #1
0
ファイル: Tween`2.cs プロジェクト: request-time-out/A-Scripts
        public IObservable <Unit> ToObservable(bool stopWhenDisposed = true)
        {
            if (this.completedEvent == null)
            {
                this.completedEvent = new Subject <Unit>();
            }
            if (this.Status != TweenStatus.Running)
            {
                return((IObservable <Unit>)Observable.Defer <Unit>((Func <IObservable <M0> >)(() =>
                {
                    if (this.Status == TweenStatus.Stopped)
                    {
                        this.Start();
                    }
                    IObservable <Unit> observable = (IObservable <Unit>)Observable.FirstOrDefault <Unit>((IObservable <M0>) this.completedEvent);
                    return stopWhenDisposed ? (IObservable <Unit>)Observable.DoOnCancel <Unit>((IObservable <M0>)observable, (Action)(() => this.Stop())) : observable;
                })));
            }
            IObservable <Unit> observable1 = (IObservable <Unit>)Observable.FirstOrDefault <Unit>((IObservable <M0>) this.completedEvent);

            return(stopWhenDisposed ? (IObservable <Unit>)Observable.DoOnCancel <Unit>((IObservable <M0>)observable1, (Action)(() => this.Stop())) : observable1);
        }