Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to find Gameobjects in Unity

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 667
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: