Last active
December 13, 2015 20:09
-
-
Save mikamikuh/4968326 to your computer and use it in GitHub Desktop.
6-2. 景品によって得点を加算する
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
| using UnityEngine; | |
| using System.Collections; | |
| public class GameTrigger : MonoBehaviour { | |
| // スコアの合計 | |
| public int totalScore = 0; | |
| void OnTriggerEnter (Collider col) | |
| { | |
| // 景品コンポーネントを取得 | |
| ItemObject obj = col.gameObject.GetComponent<ItemObject>(); | |
| if(obj != null) { | |
| // 取得出来たら(景品だったら)スコアを加算 | |
| totalScore += obj.score; | |
| } | |
| Destroy (col.gameObject); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment