// Start is called before the first frame update void Start() { var stringReactiveProperty = new StringReactiveProperty(); mInputField = transform.Find("InputField").GetComponent <InputField>(); mText = transform.Find("Text").GetComponent <Text>(); //mInputField.BindTextTo(stringReactiveProperty); //mText.BindTextTo(stringReactiveProperty); //var inputFieldReactiveProperty = new StringReactiveProperty(); //var textReactiveProperty = new StringReactiveProperty(); //mInputField.BindTextTo(inputFieldReactiveProperty); //mText.BindTextTo(textReactiveProperty); //GenericBindings.Bind(inputFieldReactiveProperty, textReactiveProperty); //GenericBindings.Bind(() => mInputField.text, x => mInputField.text = x, () => mText.text, inputValue => mText.text = inputValue, BindingsRx.BindingTypes.Default) // .AddTo(mInputField); //mInputField.BindTextTo(() => mText.text, value => mText.text = value, filters: new SampleFilter<string>(TimeSpan.FromSeconds(5.0f))); //mInputField.OnValueChangedAsObservable().SubscribeToText(mText); mInputField.Bind(mText); mInputField.OnValueChangedAsObservable().ToReactiveProperty().Subscribe(value => Debug.Log(value)); //mInputField.BindTextTo(mText); }
public AsyncLoginViewModel() { Tips = new StringReactiveProperty(INPUT_TIPS); InputNameCommand = new AsyncReactiveCommand <string>(); InputNameCommand.Subscribe(InputPassword); }
private void OnLoadComplete(List <MonsterDataModel> monsters, Dictionary <string, ElementDataModel> elements, Dictionary <string, Texture2D> images) { // Header of the view localizationService.GetString("title").Subscribe(x => view.header_title_text.text = x.ToUpper()); // Only changing the gems requires value the view will be updated with formatted text speedUpButtonText = new StringReactiveProperty(localizationService.GetString("speedup_button").Value); speedUpGemsRequired .Subscribe(gems => speedUpButtonText .Subscribe(x => view.speedup_button_text.text = string.Format(x, gems).ToUpper()) ); // When breeding time is updated the view will be notified breedingTimeLeftText = new StringReactiveProperty(localizationService.GetString("waiting").Value); breedingTimeLeft .Subscribe(t => breedingTimeLeftText .Subscribe(x => view.breeding_time_remaining_text.text = string.Format(x, "00:" + string.Format("{0:00}", t)).ToUpper()) ); view.OnSpeedUpClick += this.OnSpeedUpClick; view.OnLeftMonsterDescriptionClick += this.OnLeftInfoClick; view.OnRightMonsterDescriptionClick += this.OnRightInfoClick; }
public static void SaveString(this StringReactiveProperty selfProperty, string key) { #if UNITY_EDITOR EditorPrefs.SetString(key, selfProperty.Value); #else PlayerPrefs.SetString(key, selfProperty.Value); #endif }
public TodoModel( string _title, bool _completed = false, bool _editing = false ) { title = new StringReactiveProperty(_title); completed = new BoolReactiveProperty(_completed); editing = new BoolReactiveProperty(_editing); }
private void Awake() { Pseudo = new StringReactiveProperty(); pseudoInput.onValueChanged.AsObservable().Subscribe(pseudo => Pseudo.Value = pseudo); //Create validate pseudo command ValidatePseudo = Pseudo.Select(pseudo => !string.IsNullOrEmpty(pseudoInput.text)).ToReactiveCommand <string>(); //Validate pseudo hides the panel ValidatePseudo.Subscribe(OnValidatePseudo); }
private void OnLoadComplete(List <MonsterDataModel> monsters, Dictionary <string, ElementDataModel> elements, Dictionary <string, Texture2D> images) { // Header of the view localizationService.GetString("complete_title").Subscribe(x => view.popup_title_text.text = x.ToUpper()); speedUpButtonText = new StringReactiveProperty(localizationService.GetString("speedup_button").Value); hearthText = new StringReactiveProperty(localizationService.GetString("complete_heart").Value.ToUpper()); popupText = new StringReactiveProperty(localizationService.GetString("complete_message").Value); hearthText.SubscribeToText(view.heart_root_text); view.OnSpendGemsClick += OnSpendGemsClick; view.OnClosePopupClick += OnClosePopupClick; }
/// <summary> /// Fsm 시작. /// </summary> public void StartFsm(string initStateName) { if (_fsmStateDict.Count.Equals(0)) { Debug.Log("state is Empty"); return; } _isRunned = true; _cancellationTokenSource = new CancellationTokenSource(); _currentStateName = new StringReactiveProperty(initStateName); _stateNameDisposable = _currentStateName.Subscribe(value => { _fsmStateDict[value].Invoke(_cancellationTokenSource).Forget(); Debug.Log($"{value}"); }); }
// Use this for initialization void Start() { PlayerOneScore = new IntReactiveProperty(0); PlayerTwoScore = new IntReactiveProperty(0); PlayerOneName = new StringReactiveProperty("Player A"); PlayerTwoName = new StringReactiveProperty("Player B"); PlayerOneScore.Subscribe(score => PlayerOneScoreDisplay.text = score.ToString()); PlayerTwoScore.Subscribe(score => PlayerTwoScoreDisplay.text = score.ToString()); PlayerOneName.Subscribe(name => PlayerOneNameDisplay.text = name); PlayerTwoName.Subscribe(name => PlayerTwoNameDisplay.text = name); PlayerOneGoal .OnTriggerEnter2DAsObservable() .Where(collision => collision.gameObject.CompareTag("Puck")) .Subscribe(_ => PlayerTwoScore.Value += 1); PlayerTwoGoal .OnTriggerEnter2DAsObservable() .Where(collision => collision.gameObject.CompareTag("Puck")) .Subscribe(_ => PlayerOneScore.Value += 1); PlayerOneGoal .OnTriggerExit2DAsObservable() .Merge(PlayerTwoGoal.OnTriggerExit2DAsObservable()) .Where(ev => ev.gameObject.CompareTag("Puck")) .Delay(TimeSpan.FromSeconds(0.5)) .Subscribe(ev => { ev.gameObject .OnDestroyAsObservable() .Delay(TimeSpan.FromSeconds(1)) .Subscribe(_ => Instantiate(PuckPrefab)); ev.gameObject.SetActive(false); Destroy(ev.gameObject); }); }
public static JSONObject Serialize(this object component) { var node = new JSONObject(); foreach (var property in component.GetType().GetProperties()) { if (property.CanRead && property.CanWrite) { if (property.PropertyType == typeof(int) || property.PropertyType.IsEnum) { node.Add(property.Name, new JSONNumber((int)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(IntReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new IntReactiveProperty(); } node.Add(property.Name, new JSONNumber((int)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(float)) { node.Add(property.Name, new JSONNumber((float)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(FloatReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new FloatReactiveProperty(); } node.Add(property.Name, new JSONNumber((float)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(bool)) { node.Add(property.Name, new JSONBool((bool)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(BoolReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new BoolReactiveProperty(); } node.Add(property.Name, new JSONBool((bool)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(string)) { node.Add(property.Name, new JSONString((string)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(StringReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new StringReactiveProperty(); } node.Add(property.Name, new JSONString((string)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(Vector2)) { var jsonObject = ((Vector2)property.GetValue(component, null)).AsJSONObject(); node.Add(property.Name, jsonObject); continue; } if (property.PropertyType == typeof(Vector2ReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new Vector2ReactiveProperty(); } var jsonObject = reactiveProperty.Value.AsJSONObject(); node.Add(property.Name, jsonObject); continue; } if (property.PropertyType == typeof(Vector3)) { var jsonObject = ((Vector3)property.GetValue(component, null)).AsJSONObject(); node.Add(property.Name, jsonObject); continue; } if (property.PropertyType == typeof(Vector3ReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new Vector3ReactiveProperty(); } var jsonObject = reactiveProperty.Value.AsJSONObject(); node.Add(property.Name, jsonObject); continue; } if (property.PropertyType == typeof(Color)) { var jsonObject = ((Color)property.GetValue(component, null)).AsJSONObject(); node.Add(property.Name, jsonObject); continue; } if (property.PropertyType == typeof(ColorReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as ColorReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new ColorReactiveProperty(); } var jsonObject = reactiveProperty.Value.AsJSONObject(); node.Add(property.Name, jsonObject); continue; } } } return(node); }
// Use this for initialization void Start() { PlayerOneScore = new IntReactiveProperty(0); PlayerTwoScore = new IntReactiveProperty(0); PlayerOneName = new StringReactiveProperty("Player A"); PlayerTwoName = new StringReactiveProperty("Player B"); PlayerOneScore.Subscribe( score => PlayerOneScoreDisplay.text = score.ToString()); PlayerTwoScore.Subscribe( score => PlayerTwoScoreDisplay.text = score.ToString()); PlayerOneName.Subscribe( name => PlayerOneNameDisplay.text = name); PlayerTwoName.Subscribe( name => PlayerTwoNameDisplay.text = name); PlayerOneGoal .OnTriggerEnter2DAsObservable () .Where (collision => collision.gameObject.CompareTag("Puck")) .Subscribe (_ => PlayerTwoScore.Value += 1); PlayerTwoGoal .OnTriggerEnter2DAsObservable () .Where (collision => collision.gameObject.CompareTag("Puck")) .Subscribe (_ => PlayerOneScore.Value += 1); PlayerOneGoal .OnTriggerExit2DAsObservable () .Merge (PlayerTwoGoal.OnTriggerExit2DAsObservable()) .Where (ev => ev.gameObject.CompareTag("Puck")) .Delay (TimeSpan.FromSeconds (0.5)) .Subscribe(ev => { ev.gameObject .OnDestroyAsObservable () .Delay (TimeSpan.FromSeconds (1)) .Subscribe (_ => Instantiate (PuckPrefab)); ev.gameObject.SetActive (false); Destroy (ev.gameObject); }); }
private void OnLoadComplete(List <MonsterDataModel> monsters, Dictionary <string, ElementDataModel> elements, Dictionary <string, Texture2D> images) { localizationService.GetString("title").Subscribe(x => view.header_title_text.text = x.ToUpper()); // Init breeding button text values breedingButtonNormalText = localizationService.GetString("select_button").Value; breedingButtonSelectedText = localizationService.GetString("select_button_selected").Value; breedingButtonText = new StringReactiveProperty(breedingButtonNormalText); breedingButtonText.Subscribe(x => view.breeding_button_text.text = x.ToUpper()); view.OnStartBreedingClick += this.OnStartBreedingClick; this.DisableBreeding(); this.monsters = monsters; this.elements = elements; this.images = images; // Load Monster Lists inside scrollers views for (int i = 0; i < monsters.Count; ++i) { // Fill RIGHT LIST GameObject goR = monsterRowFactory.Create(); goR.name = "monster_right_0" + i.ToString(); goR.transform.SetParent(view.right_list_root, false); // Init monster view with info from model MonsterDataModel m = monsters[i]; MonsterRowView mView = goR.transform.GetComponent <MonsterRowView>(); mView.init(i, MonsterRowView.TableSide.RIGHT); //assign to the view an id number // Assing click delegates mView.OnMonsterClick += OnMonsterClick_NotSelected; mView.monster_thumb_image.texture = (Texture)images[m.thumb_img]; mView.monster_level_text.text = m.level.ToString(); mView.monster_name_text.text = m.name; mView.monster_type_text.text = m.type; int counter = 0; foreach (string elemName in m.elements) { mView.monster_elements[counter].enabled = true; mView.monster_elements[counter].texture = images[elements[elemName].img]; ++counter; } // Fill LEFT LIST // Load Monster Lists inside scrollers GameObject goL = monsterRowFactory.Create(); goL.name = "monster_left_0" + i.ToString(); goL.transform.SetParent(view.left_list_root, false); mView = goL.transform.GetComponent <MonsterRowView>(); mView.init(i, MonsterRowView.TableSide.LEFT); //assign to the view an id number // Assing click delegates mView.OnMonsterClick += OnMonsterClick_NotSelected; mView.monster_thumb_image.texture = (Texture)images[m.thumb_img]; mView.monster_level_text.text = m.level.ToString(); mView.monster_name_text.text = m.name; mView.monster_type_text.text = m.type; counter = 0; foreach (string elemName in m.elements) { mView.monster_elements[counter].enabled = true; mView.monster_elements[counter].texture = images[elements[elemName].img]; ++counter; } } view.ShowView(); }
private static void ApplyValue(object component, JSONNode node, PropertyInfo property) { if (property.CanRead && property.CanWrite) { var propertyData = node[property.Name]; if (propertyData == null) { return; } if (property.PropertyType == typeof(int)) { property.SetValue(component, propertyData.AsInt, null); return; } if (property.PropertyType == typeof(IntReactiveProperty)) { var reactiveProperty = new IntReactiveProperty(propertyData.AsInt); property.SetValue(component, reactiveProperty, null); return; } if (property.PropertyType == typeof(float)) { property.SetValue(component, propertyData.AsFloat, null); return; } if (property.PropertyType == typeof(FloatReactiveProperty)) { var reactiveProperty = new FloatReactiveProperty(propertyData.AsFloat); property.SetValue(component, reactiveProperty, null); return; } if (property.PropertyType == typeof(bool)) { property.SetValue(component, propertyData.AsBool, null); return; } if (property.PropertyType == typeof(BoolReactiveProperty)) { var reactiveProperty = new BoolReactiveProperty(propertyData.AsBool); property.SetValue(component, reactiveProperty, null); return; } if (property.PropertyType == typeof(string)) { property.SetValue(component, propertyData.Value, null); return; } if (property.PropertyType == typeof(StringReactiveProperty)) { var reactiveProperty = new StringReactiveProperty(propertyData.Value); property.SetValue(component, reactiveProperty, null); return; } if (property.PropertyType == typeof(Vector2)) { property.SetValue(component, propertyData.AsVector2, null); return; } if (property.PropertyType == typeof(Vector2ReactiveProperty)) { var reactiveProperty = new Vector2ReactiveProperty(propertyData.AsVector2); property.SetValue(component, reactiveProperty, null); return; } if (property.PropertyType == typeof(Vector3)) { property.SetValue(component, propertyData.AsVector3, null); return; } if (property.PropertyType == typeof(Vector3ReactiveProperty)) { var reactiveProperty = new Vector3ReactiveProperty(propertyData.AsVector3); property.SetValue(component, reactiveProperty, null); return; } } }
public ReadOnlyReactiveProperty<string> rx_get_filename_label(StringReactiveProperty rx_key) { return controller.rx_get_filename_label(rx_key);}
public ReadOnlyReactiveProperty<string> rx_load_text(StringReactiveProperty rx_key) { return controller.rx_load_text(rx_key);}
public ReadOnlyReactiveProperty<string> rx_get_filename_label(StringReactiveProperty rx_file){ return rx_file.SelectMany(key=>rx_get_filename_label(key)).ToReadOnlyReactiveProperty<string>(); }
public ReadOnlyReactiveProperty<string> rx_get_language_label(StringReactiveProperty rx_key){ return rx_key.SelectMany(key=>rx_get_language_label(key)).ToReadOnlyReactiveProperty<string>(); }
public ReadOnlyReactiveProperty<string> rx_load_text(StringReactiveProperty rx_key){ return rx_key.SelectMany(key => rx_load_text(key)).ToReadOnlyReactiveProperty<string>(); }
public static JSONClass SerializeComponent(this object component) { var node = new JSONClass(); foreach (var property in component.GetType().GetProperties()) { if (property.CanRead && property.CanWrite) { if (property.PropertyType == typeof(int)) { node.Add(property.Name, new JSONData((int)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(IntReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new IntReactiveProperty(); } node.Add(property.Name, new JSONData((int)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(float)) { node.Add(property.Name, new JSONData((float)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(FloatReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new FloatReactiveProperty(); } node.Add(property.Name, new JSONData((float)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(bool)) { node.Add(property.Name, new JSONData((bool)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(BoolReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new BoolReactiveProperty(); } node.Add(property.Name, new JSONData((bool)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(string)) { node.Add(property.Name, new JSONData((string)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(StringReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new StringReactiveProperty(); } node.Add(property.Name, new JSONData((string)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(Vector2)) { node.Add(property.Name, new JSONData((Vector2)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(Vector2ReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new Vector2ReactiveProperty(); } node.Add(property.Name, new JSONData((Vector2)reactiveProperty.Value)); continue; } if (property.PropertyType == typeof(Vector3)) { node.Add(property.Name, new JSONData((Vector3)property.GetValue(component, null))); continue; } if (property.PropertyType == typeof(Vector3ReactiveProperty)) { var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty; if (reactiveProperty == null) { reactiveProperty = new Vector3ReactiveProperty(); } node.Add(property.Name, new JSONData((Vector3)reactiveProperty.Value)); continue; } } } return(node); }
protected ResizeHandle() { _size = new FloatReactiveProperty(10); _cursor = new StringReactiveProperty(); _interactable = new BoolReactiveProperty(true); }
public TodoItem(string content, int id) { Content = new StringReactiveProperty(content); //Completed = new BoolReactiveProperty(false); Id = id; }
public void Init(string str) { _property = new StringReactiveProperty(str); _property.Subscribe(_ => _history.PushText(_)); }