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

Bug 'GameObject' does not contain a definition for 'activeInHierachy'

Discussion in 'Scripting' started by Manchine, Sep 10, 2023.

  1. Manchine

    Manchine

    Joined:
    Sep 1, 2023
    Posts:
    2
    Old guy trying to learn here. =)

    First real error I have run into where I can't figure out. I can't seem to figure out why this one is appearing. Any help would be appreciated.

    Entire Error
    Assets\Scripts\MenuManager.cs(24,21): error CS1061: 'GameObject' does not contain a definition for 'activeInHierachy' and no accessible extension method 'activeInHierachy' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)

    upload_2023-9-10_17-36-9.png
     
  2. BABIA_GameStudio

    BABIA_GameStudio

    Joined:
    Mar 31, 2020
    Posts:
    492
    Bunny83 likes this.
  3. Manchine

    Manchine

    Joined:
    Sep 1, 2023
    Posts:
    2
    I checked that out and I don't know how many times I looked at that to make sure it was spelled right even after coming here and looking at other examples and seeing that is the most common mistake.

    Thank you.
     
    Bunny83 likes this.
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,778
    This isn't a post for the 2D forum. For scripting posts (or general typos) please use the Scripting forum or consider using the Getting Started forum.

    I'll move your post to the Scripting forum for you.

    Thanks.
     
    Bunny83 likes this.
  5. ijmmai

    ijmmai

    Joined:
    Jun 9, 2023
    Posts:
    188

    You could simplify to:

    Code (CSharp):
    1.  
    2. menu.SetActive(!menu.activeInHierarchy)
    3.