facebook twitter hatena line email

「Unity/UniRx/値変更検知」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(同じ利用者による、間の19版が非表示)
行1: 行1:
==値変更検知サンプル==
+
[[Unity/UniRx/値変更検知/方法]]
IsCompletedが、trueになったときに、検知
+
<pre>
+
sampleClient.ObserveEveryValueChanged(x => x.IsCompleted)
+
            .Subscribe(isCompleted =>
+
            {
+
                // 値が変更が入ると処理される
+
                if (!isCompleted) return;
+
                Debug.Log("isCompleted=" + isCompleted);
+
                Debug.Log("sampleClient.Url=" + sampleClient.Url);
+
            })
+
            .AddTo(gameObject);
+
</pre>
+
  
==全体サンプル==
+
[[Unity/UniRx/値変更検知/ObserveEveryValueChanged]]
<pre>
+
using UnityEngine;
+
using UniRx;
+
  
public class ChangeValueScene : MonoBehaviour
+
[[Unity/UniRx/値変更検知/ReactiveProperty]]
{
+
 
    class SampleClient
+
[[Unity/UniRx/値変更検知/配列]]
    {
+
 
        public bool IsCompleted = false;
+
[[Unity/UniRx/値変更検知/ObserveEveryValueChanged配列]]
        public string Url = "ttp://example.com";
+
        public void Request()
+
        {
+
            IsCompleted = true;
+
        }
+
    }
+
    void Start()
+
    {
+
        var sampleClient = new SampleClient();
+
        sampleClient.Request();
+
        sampleClient.ObserveEveryValueChanged(x => x.IsCompleted)
+
            .Subscribe(isCompleted =>
+
            {
+
                // 値が変更が入ると処理される
+
                if (!isCompleted) return;
+
                Debug.Log("isCompleted=" + isCompleted);
+
                Debug.Log("sampleClient.Url=" + sampleClient.Url);
+
            })
+
            .AddTo(gameObject);
+
    }
+
}
+
</pre>
+

2022年3月24日 (木) 20:55時点における版

Unity/UniRx/値変更検知/方法

Unity/UniRx/値変更検知/ObserveEveryValueChanged

Unity/UniRx/値変更検知/ReactiveProperty

Unity/UniRx/値変更検知/配列

Unity/UniRx/値変更検知/ObserveEveryValueChanged配列