In unity you can find gameobjects by their name or tag.
1. Find objects by Name:- You can easily find the gameobjects by their names.
Here is the simple code for this
Gameobject Abc;
void Start()
{
    Abc = GameObject.Find("Square");
}
In above code Square is the gameobject which you want to find.
2. Find objects by Tag:- Objects can also be located by giving them a tag
  and find them by tag.
Below is a simple code for this
GameObject Xyz;
void Start()
{
    Xyz= GameObject.FindWithTag("Cube");
}
You can also find multiple gameobjects  using the below code
GameObject[] Pqr;
void Start()
{
    Pqr = GameObject.FindGameObjectsWithTag("Enemy");
}
                       
                    
0 Comment(s)