Search Unity

Finding inactive objects

Discussion in 'Getting Started' started by witcher101, Sep 10, 2015.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    I am trying to activate an inactive objects. I am suing findwithtag option.
    But it seems it doesnt find objects which are inactive. Anyway to find inactive objects through code??
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    In general, no. But they do still show up in the child list of a transform, so if all your inactive objects are within some known parent transform, you can walk the list and find things that way.

    There is a feature request for improvement to this. Please vote if it matters to you.
     
  3. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    Similar to the above, would be to either
    - store it with a public variable in the inspector
    or if iyou are able with your current set up to
    - find/store it in a variable when it is active, set it to inactive, then
    - use the variable and .SetActive later on

    :)
     
    JoeStrout likes this.