Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
4
Question by sdgd · Apr 01, 2013 at 08:07 AM · c#gameobjectactivehow-tocompare

how to know if GameObject is active without getting warning?

I don't want to change it but see if it's active

 if (GOs.gameObject.active){}

the warning I get for it

 Assets/Scripts/CreateFloor.cs(263,44): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'

why because of my pool and if I disable disabled object than it get's wrong and it may send an active GO to the wrong place and it could look like there's deleted GO but instead it's not

so any else way to compare if GO is active?

Source

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

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Chronos-L · Apr 01, 2013 at 08:12 AM

GameObject.active is obsolete now. You can use GameObject.activeInHierarchy to check if the gameObject is active in the scene.

Comment
Add comment · Show 4 · 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 sdgd · Apr 01, 2013 at 08:27 AM 0
Share

ok thanks it works

what exactly means obsolete?

and wooooow my performance went down aloooot when I change only in to activeInHierarchy

avatar image Chronos-L · Apr 01, 2013 at 09:22 AM 3
Share

Obsolete can be considered to be equivalent to outdated. When a function is deemed obsolete, usually it will be replaced by newer/different function(s) that can do the same thing.

For gameObject.active, it is a getter/setter. The setter is replaced by gameObject.SetActive(); while the getter is replaced by 2 getters: activeInHierarchy and activeSelf.

avatar image sdgd · Apr 01, 2013 at 11:10 AM 0
Share

gr8 thanks now I know why performance droped I used activeself after I read this 2 articles you provided and it's parents are allways active anyway so for few 100 in few seconds that's huge difference

avatar image Shippety · Mar 11, 2015 at 06:29 PM 0
Share

Oh! So helpful, thanks!

avatar image
0

Answer by CiberX15 · Sep 21, 2015 at 11:27 PM

I think you can also use GameObject.activeSelf which I imagine would be faster, but it only checks that specific object and won't necessarily return false if the parent is disabled.

Reference: http://docs.unity3d.com/ScriptReference/GameObject-activeSelf.html

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Multiple Cars not working 1 Answer

How can I check if a specific gameObject is located in a specific "room"? 2 Answers

What is the way of checking if gameobjects are the same in build?,What is the right way of checking if an object is the same as another object in build? 0 Answers

Get Object that Instantiated this object 1 Answer

Activating GameObjects one by one 2 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