LoginSignup
1
4

More than 5 years have passed since last update.

Unityでタグから複数のゲームオブジェクトの数を取得するメモ

Last updated at Posted at 2017-04-09

FindTagで良いかと思っていたけど、これだと1件しか取得できないぽい。
複数件取得するにはFindGameObjectsWithTagを使う

全ゲームオブジェクトを読み込んでから、ゲームがスタートする時に数を初期化したいのでこんな感じで書くと良い。

int targetCount;

void Start() {
  targetCount = GameObject.FindGameObjectsWithTag ("TargetObject").Length;
}
1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4