Search Unity

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