Created
August 3, 2015 23:47
-
-
Save JavadocMD/f6e67b1b517d7068b7aa to your computer and use it in GitHub Desktop.
UniRx issue
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 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