Searching Multiple GameObjects By Unity Tag

In Unity, the FindGameObjectsWithTag() method is used to find all GameObject assigned to a Tag

The method returns an Array of GameObjects. If it can't find a result according to the specified Tag, it returns an empty array.

An example code is given below..

public class UnityTest : MonoBehaviour { public GameObject[] players; void Start() { players = GameObject.FindGameObjectsWithTag("Player"); } }

In the example, GameObject array named "players" has been created, all GameObjects with "Player" Tag are found by our method and assigned to this array.



You May Interest

GameObject Search By Unity Tag

What is Unity StartCoroutine ?

What is Unity FBX?

Running Your Unity Project From Any Visual Studio You Want

What is Unity Tag?