C#_Unity_逆引き05
■コインカウント
■ScoreText
using UnityEngine.UI;
public class ScoreText : MonoBehaviour
{
Text text;
public static int coinAmount;
// Start is called before the first frame update
void Start()
{
text = GetComponent<Text>();
}
// Update is called once per frame
void Update()
{
text.text = coinAmount.ToString();
}
}
■Coin
private void OnTriggerEnter(Collider other)
{
ScoreText.coinAmount += 1;
Destroy(gameObject);
}