public void CreateBinding(GameObject obj) { _viewGameObject = obj; _viewCanvas = _viewGameObject.GetComponent <Canvas>(); var view = obj.GetComponent <CommonTestView>(); if (view != null) { _view = view; Reset(); //回滚初始值 view.BindingContext().DataContext = this; return; } view = obj.AddComponent <CommonTestView>(); _view = view; view.FillField(); view.BindingContext().DataContext = this; BindingSet <CommonTestView, CommonTestViewModel> bindingSet = view.CreateBindingSet <CommonTestView, CommonTestViewModel>(); view.orirootLocation = _rootLocation = view.rootLocation.anchoredPosition; bindingSet.Bind(view.rootLocation).For(v => v.anchoredPosition).To(vm => vm.rootLocation).OneWay(); view.oriposText = _posText = view.posText.text; bindingSet.Bind(view.posText).For(v => v.text).To(vm => vm.posText).OneWay(); bindingSet.Build(); SpriteReset(); }
private void EventTriggerBind(CommonTestView view) { }