public MouthCellViewModel CreateAndSetUpMouthCellViewModel(int mouthIndex) { MouthCellModel model = stickerCustomizationPopupModel.GetDataWithIndex(mouthIndex); MouthCellViewModel mouthCellViewModel = new MouthCellViewModel(model, cachedResourcesLoader); mouthCellViewModel.SelectionIntent.Subscribe(_ => selectedMouthModel.OnNext(model)); selectedMouthModel.Select(x => x.Id == mouthIndex).Subscribe(mouthCellViewModel.MouthActiveObserver); return(mouthCellViewModel); }
private void Awake() { string mouthsData = Resources.Load <TextAsset>("MouthsData").text; StickerCustomizationPopupModel stickerCustomizationPopupModel = JsonUtility.FromJson <StickerCustomizationPopupModel>(mouthsData); SetViewModel(new StickerCustomizationPopupViewModel(stickerCustomizationPopupModel, new CachedResourcesLoader(), stickerCustomizationPopupModel.GetDataWithIndex(0).Id)); }
public StickerCustomizationPopupViewModel(StickerCustomizationPopupModel stickerCustomizationPopupModel, CachedResourcesLoader cachedResourcesLoader, int selectedMouthId) { selectedMouthModel = new BehaviorSubject <MouthCellModel>(stickerCustomizationPopupModel.GetDataWithIndex(selectedMouthId)); this.stickerCustomizationPopupModel = stickerCustomizationPopupModel; this.cachedResourcesLoader = cachedResourcesLoader; }