2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UniRxを使ってキーボードの入力を受け取るサンプルプログラム

Posted at

UniRxの使い方がやってわかってきたのでメモ。

個人で親指シフトの練習ソフト(WEBGL)を作っているが、
キーボードからの入力を楽に実装できないか検討した。

その結果、UniRxを使ったほうが楽に実装できることがわかった。

キーボードからの入力を取得するサンプルプログラム

以下の4行のみの実装でキーボードからの文字を取得できます。

//キーボードからの入力を取得する
var keyStream = Observable.EveryUpdate()
.Select(_ => Input.inputString) 
.Where(xs => Input.anyKeyDown)
.Subscribe(xs=> Debug.Log(xs));

UniRxは、慣れるまでそれなりに時間かかりますが、使えると開発工数が減るので幸せになれますね!

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?