This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Start() | |
{ | |
Observable.Timer(TimeSpan.FromSeconds(Random.Range(0,1.5f)) //0-1.5秒後に値を発行 | |
.Subscribe(_=> | |
{ | |
this.UpdateAsObservable().Subscribe(Action()); | |
}).AddTo(this); //このコンポーネントが削除されたら中断する | |
} | |
void Action() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.UpdateAsObservable().Where( _ => Input.GetButtonDown(”Jump”) ) | |
.Subscribe(_=>{ | |
Observable.NextFrame(FrameCountType.FixedUpdate) ) | |
.Subscribe(__=> rigidBody.AddForce(Vector3.Up)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BlockCoreはGameManagerを知らない | |
calss BlcokCore : MonoBehaviour | |
{ | |
//ブロック作成通知Subject | |
private Subject<int> createBlockSubject = new Subject<int>(); | |
//ブロック破壊通知Subject | |
private Subject<int> destroyBlockSubject = new Subject<int>(); | |
//ブロック作成通知 | |
//値は生成されたブロックID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ゲームのシーン一覧を扱うenum | |
// シーン一覧をenumで定義しておくと、文字列を毎回打たなくて良いから管理がちょっと楽になる | |
// (定義する要素名はUnityのScene名と一致させておくこと) | |
public enum GameScenes | |
{ | |
Title, | |
MainMenu, | |
OptionMenu, | |
Stage1, | |
Stage2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//旧 | |
{ | |
"name": "ゆかり", | |
"text": "こんにちはみなさん", | |
"emotion": "greeting", | |
"tag": "white", | |
"isInterrupted": false | |
} | |
//2.1以降 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var IsHoldReactiveProperty = | |
this.UpdateAsObservable() | |
.Select(_ => Input.GetMouseButton(0)) | |
.Buffer(30, 1) | |
.Select(x => x.All(v => v)) | |
.ToReactiveProperty(); | |
IsHoldReactiveProperty.Subscribe(x => Debug.Log(x)); | |
Debug.Log(IsHoldReactiveProperty.Value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ファイアーボール側のOnCollisionEnterの実装例 | |
void OnCollisionEnter(Collision coll) | |
{ | |
//すでにダメージを与えた後なら何もしない | |
if (isDisabled) return; | |
// 対象がダメージを受けることができるオブジェクトであるか調べる | |
var target = coll.gameObject.GetComponent<IDmageable>(); | |
if ( target == null ) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Update() | |
{ | |
intervalTime += Time.deltaTime; | |
// マウス入力で左クリックをした瞬間 | |
if (Input.GetMouseButtonDown(0)) | |
{ | |
if (intervalTime >= 3.0f) | |
{ | |
StartCoroutine(CreatePrefabCoroutine()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestScript : MonoBehaviour | |
{ | |
public Button buttonA; | |
public Button buttonB; | |
public Button buttonC; | |
private void Start() | |
{ | |
var eventA = buttonA.OnClickAsObservable(); |