Skip to content

Instantly share code, notes, and snippets.

@maco1028
Last active July 12, 2017 02:04
Show Gist options
  • Save maco1028/7f02d9768ec9bc7da76cc1364fbf9df1 to your computer and use it in GitHub Desktop.
Save maco1028/7f02d9768ec9bc7da76cc1364fbf9df1 to your computer and use it in GitHub Desktop.
スコア加点処理 #unity
//コントローラー用(別々のスクリプト)
int score = 0;
GameObject scoreText;
public void AddScore(){
this.score += 10;
}
void Start () {
this.scoreText = GameObject.Find ("Score");
}
void Update () {
scoreText.GetComponent<Text> ().text = "Score:" + score.ToString("D4");
}
//衝突処理用
void OnCollisionEnter(Collision collision){
Destroy(collision.gameObject);
Destroy(this.gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment