Example #1
0
        private void Start()
        {
            _binder.BindAction(_carViewModel, vm => vm.Beep(), vm => _beepAudioSource.Play());

            _binder.BindProperty(_carViewModel, vm => vm.SirenIsOn,
                                 vm => _sirenAudioSource.enabled = vm.SirenIsOn, true);

            _binder.BindProperty(_carViewModel, vm => vm.HeadlightsAreOn,
                                 vm => _headLights.ForEach(p => p.enabled = vm.HeadlightsAreOn), true);

            _carViewModel.PropertyChanged += _carViewModel_PropertyChanged;
            _textMesh.text = "";
        }
        public void ShouldBindAction()
        {
            var binder = new Binder <UniversalStub>();

            binder.BindAction(x => ActionBinding(x, x.NullableInt ?? -1));

            using (binder.Attach(_stub))
            {
                _stub.Int.ShouldBe(-1);

                _stub.NullableInt = 1;
                _stub.Int.ShouldBe(1);
            }
        }