public void CreateBinding(GameObject obj) { _viewGameObject = obj; _viewCanvas = _viewGameObject.GetComponent <Canvas>(); var view = obj.GetComponent <GroupTechStatView>(); if (view != null) { _view = view; Reset(); //回滚初始值 view.BindingContext().DataContext = this; return; } view = obj.AddComponent <GroupTechStatView>(); _view = view; view.FillField(); view.BindingContext().DataContext = this; BindingSet <GroupTechStatView, GroupTechStatViewModel> bindingSet = view.CreateBindingSet <GroupTechStatView, GroupTechStatViewModel>(); view.oriShow = _show = view.Show.activeSelf; bindingSet.Bind(view.Show).For(v => v.activeSelf).To(vm => vm.Show).OneWay(); view.oriRoomInfoText = _roomInfoText = view.RoomInfoText.text; bindingSet.Bind(view.RoomInfoText).For(v => v.text).To(vm => vm.RoomInfoText).OneWay(); view.oriPlayerCountText = _playerCountText = view.PlayerCountText.text; bindingSet.Bind(view.PlayerCountText).For(v => v.text).To(vm => vm.PlayerCountText).OneWay(); bindingSet.Build(); SpriteReset(); }
private void EventTriggerBind(GroupTechStatView view) { }