Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5 .active no longer recognised

Discussion in 'Scripting' started by kalisclark, Mar 5, 2015.

  1. kalisclark

    kalisclark

    Joined:
    Sep 29, 2014
    Posts:
    33
    Hi guys,

    Just upgraded to Unity 5 and found that the following no longer works?

    transform.find("mygameobject").active = true;

    The "active" part is not recognised anymore.

    Am I missing something?
     
  2. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    gameObject.active was already deprecated/obsolete and most likely now removed. use GameObject.SetActive
     
  3. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Also, transform.Find returns a transform. So you've got to add .gameObject
    to the returned transform to make it active/ inactive using .SetActive()
     
  4. kalisclark

    kalisclark

    Joined:
    Sep 29, 2014
    Posts:
    33
    Thanks you guys! I did this...

    transform.Find("mygamobject").gameObject.SetActive(true);

    That seems to have cleared the error. Thanks again for such a swift response Timelog and gamer_boy_81