Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Start()
- {
- var mouseDownStream = Observable.EveryUpdate().Where(_ => Input.GetMouseButtonDown(0));
- var mouseUpStream = Observable.EveryUpdate().Where(_ => Input.GetMouseButtonUp(0));
- var shootStream = mouseDownStream
- // flat the mouseDown with the 0.1s interval
- .SelectMany(_ => Observable.Interval(TimeSpan.FromSeconds(0.1f)))
- .TakeUntil(mouseUpStream)// stop shooting when mouseUp emit
- .RepeatSafe()// repeat the process
- .Subscribe(_ => Shoot());
- }
- void Shoot()
- {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement