private void OnEnable() { ConnectSocket(); _isConnectedObserver = _isConnected.Subscribe(status => { if (status) { return; } _reconnectObserver = Observable.Interval(TimeSpan.FromSeconds(5)) .TakeUntil(_isConnected.Where(connected => connected)) .Subscribe(observer => { _activeClients = new List <UnityUser>(); ConnectSocket(); Debug.Log("Trying to reconnect " + _socket.State); }); }); _serverJsonObserver = _serverJson.Subscribe(value => { _activeClients = value?.FromJson <List <UnityUser> >(); var currentUser = _activeClients.Find(u => u.Id == SystemInfo.deviceUniqueIdentifier); _activeObject = string.IsNullOrEmpty(currentUser.LockedAsset) ? null : AssetDatabase.LoadMainAssetAtPath(currentUser.LockedAsset); Repaint(); }); }
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; }
// Start is called before the first frame update void Start() { var rp = new ReactiveProperty <int>(10); //値の代入と取り出し rp.Value = 20; var currentValu = rp.Value; rp.Subscribe(x => Debug.Log(x)); rp.Dispose(); rp.Value = 30; _intReactiveProperty.Subscribe(x => Debug.Log("IRP:" + x)); _intReactiveProperty.Value = 1000; _intReactiveProperty.Value = 2000; _stringReactiveProperty.Subscribe(s => Debug.Log("String:" + s)); _boolReactiveProperty.Subscribe(b => { if (b) { Debug.Log("Message True."); } else { Debug.Log("Message False."); } }); }
private void Start() { _loginManager.IsLoggedIn .Where(x => x) //ログイン時 .Subscribe(x => { //APIクライアント作成 _nicoliveApiClient = new NicoliveApiClient(_loginManager.CurrentUser); }); //ログインできたら表示を切り替える _loginManager.IsLoggedIn.Subscribe(x => { _loginPanel.SetActive(!x); _mainPanel.SetActive(x); }); //対象番組設定 _currentProgramId.Subscribe(x => { if (_nicoliveApiClient != null) { _nicoliveApiClient.SetNicoliveProgramId(x); } }); }
private void OnNewSpeedUpRequest(BreedingStatusModel status) { breedingStatus = status; breedingStatus.timeLeft .Subscribe(t => { status.gemsRequired.Subscribe(gems => { speedUpButtonText .Subscribe(x => { view.speedup_button_text.text = string.Format(x, gems).ToUpper(); }); popupText .Subscribe(p => { view.popup_text.text = string.Format(p, t + "s", gems); }); }); } ); view.ShowView(); }
private void Awake() { tgeSelect.group = transform.parent.GetComponent <ToggleGroup>(); Name.SubscribeToText(txtName).AddTo(gameObject); Name.Subscribe(x => { inputName.text = x; }).AddTo(gameObject); btnEditor.OnClickAsObservable().Subscribe(x => { inputName.gameObject.SetActive(true); inputName.ActivateInputField(); }).AddTo(gameObject); }
protected override void InitializeComponent(IUIContext context, bool isPlaying) { base.InitializeComponent(context, isPlaying); _value .Subscribe(v => PeerInput.text = v, Debug.LogError) .AddTo(this); if (!isPlaying) { return; } PeerInput .OnValueChangedAsObservable() .Subscribe(v => Value = v, Debug.LogError) .AddTo(this); _readOnly .Subscribe(v => PeerInput.readOnly = v, Debug.LogError) .AddTo(this); _characterLimit .Subscribe(v => PeerInput.characterLimit = v, Debug.LogError) .AddTo(this); _caretWidth .Subscribe(v => PeerInput.caretWidth = v, Debug.LogError) .AddTo(this); _placeholderText .Subscribe(UpdatePlaceholder, Debug.LogError) .AddTo(this); _textStyle .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerText, DefaultTextStyle), Debug.LogError) .AddTo(this); _placeholderTextStyle .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerPlaceholder, DefaultPlaceholderStyle), Debug.LogError) .AddTo(this); _background .Select(v => v.ValueFor(this)) .Subscribe(v => v.Update(PeerBackground, DefaultBackground), Debug.LogError) .AddTo(this); _selectionColor .Select(v => v.OrDefault(DefaultSelectionColor)) .Subscribe(v => PeerInput.selectionColor = v, Debug.LogError) .AddTo(this); _caretColor .Select(v => v.HasValue ? v : DefaultCaretColor) .Subscribe(v => { PeerInput.customCaretColor = v.HasValue; PeerInput.caretColor = v.OrDefault(Color.black); }, Debug.LogError) .AddTo(this); }
/// <summary> /// InspectorからのReactiveProperty /// </summary> private void ExcuteInspectorRP() { _intRp.Subscribe(x => { Debug.Log("int RP : " + x); }); _stringRp.Subscribe(x => { Debug.Log("string RP : " + x); }); }
void Start() { SinglelineString.Subscribe(x => { Debug.Log(x); }); MultineString.Subscribe(x => { Debug.Log(x); }); }
void Start() { canvas = GetComponentInChildren <Canvas>(); aliasText = canvas.transform.Find("Alias").GetComponent <Text>(); team.Subscribe(newTeam => { var teamName = newTeam.ToString("G"); var playerMaterial = Resources.Load <Material>($"Materials/Player/{teamName}"); GetComponent <Renderer>().material = playerMaterial; }); alias.Subscribe(newAlias => aliasText.text = newAlias); }
void Start() { intProperty.Subscribe(it => Debug.Log(it)); longProperty.Subscribe(it => Debug.Log(it)); floatProperty.Subscribe(it => Debug.Log(it)); doubleProperty.Subscribe(it => Debug.Log(it)); byteProperty.Subscribe(it => Debug.Log(it)); boolProperty.Subscribe(it => Debug.Log(it)); stringProperty.Subscribe(it => Debug.Log(it)); vector2Property.Subscribe(it => Debug.Log(it)); vector3Property.Subscribe(it => Debug.Log(it)); vector4Property.Subscribe(it => Debug.Log(it)); quaternionProperty.Subscribe(it => Debug.Log(it)); colorProperty.Subscribe(it => Debug.Log(it)); boundsProperty.Subscribe(it => Debug.Log(it)); animationCurveProperty.Subscribe(it => Debug.Log(it)); }
/// <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 void Init(string str) { _property = new StringReactiveProperty(str); _property.Subscribe(_ => _history.PushText(_)); }
private void Start() { inputText_.Subscribe(WriteAlphabet); }
// 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 Start() { inputDigit_.Subscribe(WriteDigits); }
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(); }