Skip to content

A Unity playground for UniRx visualization inspired by rxmarbles.com

License

Notifications You must be signed in to change notification settings

Jacykow/Unirx-Playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unirx Playground

A Unity playground for UniRx visualization inspired by rxmarbles.com.

Usage

After downloading the source code simply press play on the MainScene. The default choice is a SelectMany visualization which is one of the prepared examples. Check out other prepared examples in the Example script. You can write your own examples in this class and run them by changing exampleId in the inspector.

Select Many Example Visualization

How does this work?

Observable usage normally would look something like this:

SomeObservable
    .UniRxExtensionMethod1()
    .UniRxExtensionMethod2()
    .Subscribe(value => OnNext(value))
    .AddTo(this);

To visualize an observable you need to convert it to IObservable<RxMessageVisualizationData>. Any observable of this type can be visualized by the Visualize extension method.

SomeObservable
    .UniRxExtensionMethod1()
    .UniRxExtensionMethod2()
    .AsVisualizationDataObservable()
    .Visualize("Timeline Title")
    .Subscribe()
    .AddTo(RxTimelineManager.Main.DisposeBag);

The conversion to IObservable<RxMessageVisualizationData> can be done easily via the AsVisualizationDataObservable extension method. Without any given parameters the color will be a random color chosen at the beginning and the shown number will be an increasing integer starting from 1. If you want to keep any of the information that was contained in the original message you need to provide a selector method that will put it into the integer value or color of a message node.

There is no need to catch any messages in the subscription since all callbacks are visualized but it can still be used for debug purposes.

All subscriptions have to be destroyed at the end of the visualization in order to stop displying incoming messages. This can be ensured by adding them to RxTimelineManager.Main.DisposeBag.

All of this is necessary for the RxTimelineManager to properly invoke the Do, DoOnCompleted and DoOnError methods and add put corresponding markers on correct timelines.

About

A Unity playground for UniRx visualization inspired by rxmarbles.com

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages