LoginSignup
1
1

More than 5 years have passed since last update.

[UniRx]2つのボタンの片方を押したら両方を無効化する奴を作ってみた

Last updated at Posted at 2016-10-21

Buttonのenableで制御しても良いけどこんなかんじ

Button buttonA;
Button buttonB;

var disporserA = buttonA.ClickAsObservable()
    .Subscribe(_ =>
{
    Debug.Log("Aが押された");
}).AddTo(this);

var disporserB = buttonB.ClickAsObservable()
    .Subscribe(_ =>
{
    Debug.Log("Bが押された");
}).AddTo(this);


buttonA.ClickAsObservable().Merge(buttonB.ClickAsObservable())
    .Subscribe(_ =>
{
    disporserA.Dispose();
    disporserB.Dispose();
}).AddTo(this);
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1