You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
UniRx - Reactive Extensions for Unity / ver 5.4.0
2
2
===
3
3
Created by Yoshifumi Kawai(neuecc)
4
4
@@ -29,7 +29,7 @@ This kind of lack of composability causes operations to be close-coupled, which
29
29
30
30
Rx cures that kind of "asynchronous blues". Rx is a library for composing asynchronous and event-based programs using observable collections and LINQ-style query operators.
31
31
32
-
The game loop (every Update, OnCollisionEnter, etc), sensor data (Kinect, Leap Motion, etc.) are all types of events. Rx represents events as reactive sequences which are both easily composable and support time-based operations by using LINQ query operators.
32
+
The game loop (every Update, OnCollisionEnter, etc), sensor data (Kinect, Leap Motion, VR Input, etc.) are all types of events. Rx represents events as reactive sequences which are both easily composable and support time-based operations by using LINQ query operators.
33
33
34
34
Unity is generally single threaded but UniRx facilitates multithreading for joins, cancels, accessing GameObjects, etc.
35
35
@@ -320,7 +320,7 @@ public class MyComponent : MonoBehaviour
Supported triggers are listed in [UniRx.wiki#UniRx.Triggers](https://github.com/neuecc/UniRx/wiki#unirxtriggers).
324
324
325
325
These can also be handled more easily by directly subscribing to observables returned by extension methods on Component/GameObject. These methods inject ObservableTrigger automaticaly (except for `ObservableEventTrigger` and `ObservableStateMachineTrigger`):
var www = ObservableWWW.Get("http://aaa").ToYieldInstruction();
703
+
while (!www.IsDone)
704
+
{
705
+
yield return null;
706
+
}
707
+
708
+
if (www.HasResult)
709
+
{
710
+
UnityEngine.Debug.Log(www.Result);
711
+
}
712
+
}
713
+
```
714
+
680
715
uGUI Integration
681
716
---
682
717
UniRx can handle `UnityEvent`s easily. Use `UnityEvent.AsObservable` to subscribe to events:
@@ -937,7 +972,7 @@ Yellow is `Awake`, order is indeterminate. Green is `BeforeInitialize` phase, it
937
972
938
973
If you create `PresenterBase` dynamically for example from Prefab, you can call `ForceInitialize(argument)` after instantiate.
939
974
940
-
ReactiveCommand
975
+
ReactiveCommand, AsyncReactiveCommand
941
976
---
942
977
ReactiveCommand abstraction of button command with boolean interactable.
943
978
@@ -961,7 +996,7 @@ public class Player
961
996
}
962
997
}
963
998
964
-
public class Presenter
999
+
public class Presenter : MonoBehaviour
965
1000
{
966
1001
public Button resurrectButton;
967
1002
@@ -977,7 +1012,68 @@ public class Presenter
977
1012
}
978
1013
```
979
1014
980
-
MessageBroker
1015
+
AsyncReactiveCommand is a variation of ReactiveCommand that `CanExecute`(in many cases bind to button's interactable) is changed to false until asynchronous execution was finished.
* `()` - CanExecute is changed to false until async execution finished
1047
+
* `(IObservable<bool> canExecuteSource)` - Mixed with empty, CanExecute becomes true when canExecuteSource send to true and does not executing
1048
+
* `(IReactiveProperty<bool> sharedCanExecute)` - share execution status between multiple AsyncReactiveCommands, if one AsyncReactiveCommand is executing, other AsyncReactiveCommands(with same sharedCanExecute property) becomes CanExecute false until async execution finished
1049
+
1050
+
```csharp
1051
+
public class Presenter : MonoBehaviour
1052
+
{
1053
+
public UnityEngine.UI.Button button1;
1054
+
public UnityEngine.UI.Button button2;
1055
+
1056
+
void Start()
1057
+
{
1058
+
// share canExecute status.
1059
+
// when clicked button1, button1 and button2 was disabled for 3 seconds.
1060
+
1061
+
var sharedCanExecute = new ReactiveProperty<bool>();
AsyncMessageBroker.Default.PublishAsync(new TestArgs { Value = 3000 })
1109
+
.Subscribe(_ =>
1110
+
{
1111
+
UnityEngine.Debug.Log("called all subscriber completed");
1112
+
});
1113
+
```
1114
+
1115
+
UniRx.Toolkit
1116
+
---
1117
+
`UniRx.Toolkit` includes serveral Rx-ish tools. Currently includes `ObjectPool` and `AsyncObjectPool`. It can `Rent`, `Return` and `PreloadAsync` for fill pool before rent operation.
For Visual Studio 2015 users, a custom analyzer, UniRxAnalyzer, is provided. It can, for example, detect when streams aren't subscribed to.
@@ -1023,37 +1205,53 @@ Therefore, when using NETFX_CORE, please refrain from using such constructs as `
1023
1205
1024
1206
DLL Separation
1025
1207
---
1026
-
If you want to pre-build UniRx, you can build own dll. clone project and open `UniRx.sln`, you can see `UniRx`, it is fullset separated project of UniRx. You should define compile symbol like `UNITY;UNITY_5_3_0;UNITY_5_3;UNITY_5;` + `UNITY_EDITOR`, `UNITY_IPHONE` or other platform symbol. We can not provides pre-build binary to release page, asset store because compile symbol is different each other.
1208
+
If you want to pre-build UniRx, you can build own dll. clone project and open `UniRx.sln`, you can see `UniRx`, it is fullset separated project of UniRx. You should define compile symbol like `UNITY;UNITY_5_4_OR_NEWER;UNITY_5_4_0;UNITY_5_4;UNITY_5;` + `UNITY_EDITOR`, `UNITY_IPHONE` or other platform symbol. We can not provides pre-build binary to release page, asset store because compile symbol is different each other.
1027
1209
1028
1210
If you want to use UniRx for .NET 3.5 normal CLR application, you can use `UniRx.Library`. `UniRx.Library` is splitted UnityEngine dependency, build `UniRx.Library` needs to define `UniRxLibrary` symbol. pre-build `UniRx.Library` binary, it avilable in NuGet.
* [Reactive Game Architectures](http://sugarpillstudios.com/wp/?page_id=279)
1220
+
* [ReactiveX](http://reactivex.io/)
1039
1221
1040
-
Introduction on how to use Rx for game programming.
1222
+
The home of ReactiveX. [Introduction](http://reactivex.io/intro.html), [All operators](http://reactivex.io/documentation/operators.html) are illustrated with graphical marble diagrams, there makes easy to understand. And UniRx is official [ReactiveX Languages](http://reactivex.io/languages.html).
- [PhotonWire](https://github.com/neuecc/PhotonWire) - Typed Asynchronous RPC Layer for Photon Server + Unity.
1249
+
- [uFrame Game Framework](https://www.assetstore.unity3d.com/en/#!/content/14381) - MVVM/MV* framework designed for the Unity Engine.
1250
+
- [EcsRx](https://github.com/grofit/ecsrx) - A simple framework for unity using the ECS paradigm but with unirx for fully reactive systems.
1251
+
- [ActionStreetMap Demo](https://github.com/ActionStreetMap/demo) - ASM is an engine for building real city environment dynamically using OSM data.
1252
+
- [utymap](https://github.com/reinterpretcat/utymap) - UtyMap is library for building real city environment dynamically using various data sources (mostly, OpenStreetMap and Natural Earth).
1055
1253
1056
-
UniRx is an official ReacitveX family language.
1254
+
If you use UniRx, please comment to [UniRx/issues/152](https://github.com/neuecc/UniRx/issues/152).
0 commit comments