1.新規でGameObjectを作成し、以下のようなスクリプトをアタッチする。
public class GameController : MonoBehaviour { public Text scoreLabel; public GameObject winnerLabelObject; public void Update() { int count = GameObject.FindGameObjectsWithTag("Item").Length; scoreLabel.text = count.ToString(); if(count == 0) { winnerLabelObject.SetActive(true); } } }
2.1で作成したオブジェクトに、カウントしたいゲームオブジェクトをアタッチする。