Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Created April 22, 2015 15:27
Show Gist options
  • Save TORISOUP/07d21ac470f8ccc4ad1c to your computer and use it in GitHub Desktop.
Save TORISOUP/07d21ac470f8ccc4ad1c to your computer and use it in GitHub Desktop.
ボタンの長押しを検知するが最初の数秒は無視する
private void Start()
{
var mouseDown = this.UpdateAsObservable().Where(_ => Input.GetMouseButtonDown(0));
var mouseUp = this.UpdateAsObservable().Where(_ => Input.GetMouseButtonUp(0));
this.UpdateAsObservable()
.Where(_ => Input.GetMouseButton(0))
.SkipUntil(mouseDown.Delay(TimeSpan.FromMilliseconds(1000)))
.TakeUntil(mouseUp)
.Repeat()
.Subscribe(_ => Debug.Log("aaa"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment