Skip to content

Instantly share code, notes, and snippets.

@JavadocMD
Created August 3, 2015 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JavadocMD/f6e67b1b517d7068b7aa to your computer and use it in GitHub Desktop.
Save JavadocMD/f6e67b1b517d7068b7aa to your computer and use it in GitHub Desktop.
UniRx issue
public class GameModel : MonoBehaviour {
public FloatReactiveProperty Score { get; private set; }
void Awake() {
Score = new FloatReactiveProperty(0f).AddTo(this);
}
}
public class ScoreUI : MonoBehaviour {
public Text text;
void Awake() {
text = GetComponent<Text>();
}
void Start() {
/*...GameModel...*/.Score.Subscribe(SetScore).AddTo(this);
}
void SetScore(float score) {
text.text = string.Format("{0:0} ft", score);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment