GameObject Search By Unity Tag

In Unity, the FindWithTag() method is used to search for a GameObject by the Tag assigned to it.

Note : Only 1 "Tag" can be assigned to GameObjects.

An example of its use is given below.

public class UnityTest : MonoBehaviour { public GameObject player; void Start() { player = GameObject.FindWithTag("Player"); } }

In the example we found a "GameObject" with the "Tag" in the name "Player" and assigned it to the variable "player".

If there is more than one GameObject assigned to the corresponding Tag, the "FindWithTag()" method returns the first GameObject it finds. Therefore, when using this method, it should be noted that Tag is assigned to only 1 GameObject.



You May Interest

What is Unity Sprite ?

What is Unity Asset Store?

What is Unity Idle?

What is Unity NPC?

What is Unity MonoDevelop ?