Beispiel #1
0
    internal void Awake()
    {
        // Bind buttons

        // Observables that control whether the buttons are interactable or not.
        var canStart  = _isLoading.Not();
        var canCancel = _isLoading.And(_isCancelling.Not());

        // BindTo() is a Silphid extension that subscribes the button to a canExecute observable (that determines
        // whether the button is interactable or not) and to its click event/observable (in order to trigger an action).
        // It then returns an IDisposable that can be used to remove the binding, which we then AddTo(this) (so that
        // it gets automatically disposed when this component is destroyed).
        StartButton.BindTo(canStart, StartLoading).AddTo(this);
        CancelButton.BindTo(canCancel, CancelLoading).AddTo(this);
    }