Last active
July 12, 2017 02:04
-
-
Save maco1028/7f02d9768ec9bc7da76cc1364fbf9df1 to your computer and use it in GitHub Desktop.
スコア加点処理 #unity
This file contains hidden or 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
//コントローラー用(別々のスクリプト) | |
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