Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Jul 24, 2020 at 09:34 AM by andrew-lukasik for the following reason:

The question is answered, right answer was accepted

avatar image
16
Question by Samael_00001 · Sep 14, 2014 at 04:48 PM · activewarning

How to check if object is active?

  if (game_object.active == true)

I'm looking for another way to do it because this way gives me a warning message: "warning CS0618: `UnityEngine.GameObject.active' is obsolete"

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image
34
Best Answer

Answer by vexe · Sep 14, 2014 at 04:57 PM

Use activeSelf

 print(go.activeSelf ? "Active" : "Inactive");

Also worth checking: SetActive, activeInHierarchy

Comment
Add comment · Show 15 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vexe · Sep 15, 2014 at 06:31 AM 3
Share

wha???????...... o_O I just answered you... hello?

 if (myGameObject.activeSelf)
    print ("Active")
avatar image Necrohunter vexe · Dec 04, 2019 at 05:22 PM 6
Share

maybe he asked again because like no beginner understands what you answered...

avatar image vexe · Sep 15, 2014 at 06:47 AM 2
Share

$$anonymous$$aybe the ternary operator confused you?

 int x = condition ? 10 : 15;

is the equivalent of:

 int x;
 if (condition)
   x = 10;
 else x = 15;

'if' takes a boolean expression which could either return a true or false. bool variables could hold a value of true or false so you could pass them to the if statement so you don't need to say:

 if (condition == true)
    doStuff();

you could just say:

 if (condition)
    doStuff();





avatar image revonas vexe · Jul 15, 2017 at 09:31 AM 0
Share

Thank you, vexe, your explanation is very detailed <3

avatar image vexe · Sep 15, 2014 at 07:03 AM 5
Share

$$anonymous$$aybe you need to consider a program$$anonymous$$g course before you approach Unity and game development in general. This is one of the many things I don't like about Unity, is that they make it sound like you don't need any program$$anonymous$$g skills to get started 'making games' - we end up with basic 101 program$$anonymous$$g questions on a technical Unity Q/A site, then you get moderators and such telling the questerioners that UA is for asking technical questions about Unity3D! forgetting the fact that Unity IS ACTUALLY promoting this stuff... (ranting about Unity, not you dear Samuel - there's nothing wrong about being a beginner - we all were)

Dear Samuel, before you build something very sophisticated as games, you need to know your tools - you need to know your language very well :) - Jamie $$anonymous$$ing is a good place to start. Start with his basic C# series and move up. Best of luck.

Also don't relate "not knowing" into giving up and asking - you could have easily found the answer by just looking at the doc for GameObject.

avatar image mohaned1001 vexe · Jan 21, 2019 at 09:49 AM 3
Share

there is no need to be this rude its not known formula that you used to answer and you assumed that every programmer will understand it " i have been studying program$$anonymous$$g for three years now and i didnt understand your code at first " also i dont think you should assume every one asking here is program$$anonymous$$g expert most of people learn unity have no program$$anonymous$$g background and they started learning program$$anonymous$$g as they learn unity so i think you should assume when you answer someone question that he is beginner
also after all it wasn't big deal to just write simple answer that every one could understand like the answer in the comment below its almost the same amount of code with less amount of explanation needed after it "no need to show skills"

avatar image toishaanpatel vexe · Jul 24, 2020 at 11:07 AM 1
Share

Dude, smartass, you should refer to the title of this website... A UNITY FORU$$anonymous$$ for program$$anonymous$$g solutions... not a Unity feedback/opinion website. And you DON'T NEED TO RUB in his face that he is a beginner: "(ranting about Unity, not you dear Samuel - there's nothing wrong about being a beginner - we all were)". Nobody cares about your opinion, so you can just keep your bullshit to yourself. Your part was done when you explained what the ternary operator does. I actually started program$$anonymous$$g through watching others do unity C# and EXPERI$$anonymous$$ENTING on my own by also asking questions, and then moved to other program$$anonymous$$g languages later on, but this helped me pick up fundamentals. Not everyone is the type of person who watches some random person code, and become a professional.

avatar image mpbMKE · Aug 13, 2019 at 04:26 AM 2
Share

Google indexes the answers on this forum, so when people are just trying to get a simple answer for syntax they don't need this kind of petty, gatekeepery garbage wasting their time. Don't want to answer a noob question? Don't answer it. Problem solved, move on, don't be a dick. Can't not be a dick? Then please know that you are, sir, a dick, and you have wasted not only your own time, but the time of everyone who just wanted a simple syntax answer and had the absolute gall to use a search engine on the internet to find it.

avatar image ula · Jun 27, 2021 at 09:24 AM 2
Share

I am so confused, one person asks a question then another one aswers it in a way they assume is the most comprehensible and neat and when it's not understood he even goes into more detail and recommends a way how to improve oneself but then there are other people who just assume that he has some kind of prejudice. What if the way he recommends is the way that worked for him? Is it so hard to google one more step? I mean if he really wants to learn I would assume he is prepared to go down the rabbit hole if he didn't master the basics first. When did Unity forum become a third-rate drama forum... no idea, please guys be less touchy-feely.

Show more comments
avatar image
53

Answer by jfn73150 · Sep 21, 2018 at 05:11 PM

I don't know why but it seems some people can't give a simple answer they have to act smart or something... Want to make you feel like you aren't ready... I also know this post is 4 years old.. But seriously... Simple answer is

 if(gameObject.ActiveSelf == true)



Sorry it took so long... Answers.Unity can be super helpful.. And sometimes it makes things worse.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Maverickthebest · Jan 24, 2019 at 12:50 AM 4
Share

@jfn73150 thanks man! This helped me a lot! That kind of answers i like!! But just one tiny detail: it worked for me only with a small "a" in Active if(gameObject.activeSelf == true)

avatar image mpbMKE · Aug 13, 2019 at 04:28 AM 4
Share

Thank you, I wasn't expecting a Google search to drop me into somebody's hissy fit over being asked a simple question that he had no obligation to answer, and I appreciate you taking the time to do so.

avatar image benjakkuekkusu · Nov 24, 2020 at 07:37 AM 0
Share

Comepletely agree, thanks so much for a simple solution

Follow this Question

Answers Answers and Comments

45 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Keep the scren active in mobile games 0 Answers

Can't reactivate object after I set it to inactivate 1 Answer

Warning on Setting Particle System Variable 1 Answer

How to create an if statement for each element within a list C# 2 Answers

Check if gameobject set to active regardless of its parents settings? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges