Already early on in 'The Tribe Must Survive', we started using UniRx, an implementation of ReactiveX for Unity. Reactive programming helps us in tremendous ways when it comes to updating the UI whenever the model changes. Also unregistering listeners when the UI is destroyed is much easier with the reactive model compared to using classic C# events.
When using UniRx, you often face the following two scenarios:
Observing a single value:
E.g. an antelope moves and therefore changes its position. You would like to observe its position so that you can change the position of the corresponding MonoBehaviour.
Observing a collection of objects:
E.g. a herd contains many antelopes. You would like to observe the entire collection, so that you are notified, when e.g. one antelope was removed from the collection.
- Observing a single value: