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
1
Question by Fattie · Sep 25, 2013 at 07:18 AM · componentenabled

Is component.enabled Deprecated? Did it ever exist?

In fact, did Component.enabled ever exist?

Is it deprecated or not, does anyone know?

In the Editor when you toggle a component on and off, what are you doing? Or, is it the case that (in fact) you can only toggle-on-and-off the, err, 20 or so derived which do have .enabled which appear in a list like this: http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=enabled

(Note that notably, Monobehaviour does have enabled, which as far as I know turns on and off the Update() function.)

So again in short ... did component.enabled (as such) ever exist?

Comment
Add comment · Show 2
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 robertbu · Sep 25, 2013 at 07:32 AM 1
Share

Actually Component does not have an enabled flag. The Behaviour class, which is derived from Component, introduces the enabled flag. $$anonymous$$onobehaviour is derived from Behaviour. To the best of my knowledge, it is not depreciated, but I'm not the authority.

avatar image Fattie · Sep 25, 2013 at 07:41 AM 0
Share

Robert - do you happen to know, did component (itself) EVER HAD an enabled flag? Perhaps that's my basic confusion and idiocy here. Thank you so much.

2 Replies

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

Answer by Bunny83 · Sep 25, 2013 at 08:36 AM

The component class itself never had an enabled property. A lot other built in components have their "own" enabled property, like Renderer, Collider, ParticleEmitter, .... Those "enabled" properties have nothing in common except the name. In other words there's no way to use some kind of base class to handle them all since they aren't related (in the sense of inheritance)

Comment
Add comment · Show 1 · 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 Fattie · Sep 25, 2013 at 08:46 AM 0
Share

This is utterly the answer.

avatar image
1

Answer by robhuhn · Sep 25, 2013 at 08:04 AM

enabled is not deprecated. In Unity 4 they only changed the active handling:

GameObject.active and GameObject.SetActiveRecursively() have been deprecated. Instead, you should now use the GameObject.activeSelf and GameObject.activeInHierarchy getters and the GameObject.SetActive() method.

You would still use enabled to enable and disable { items such as behaviours, as @robertbu said } [Ed: I slightly changed this sentence to avoid mass confusion! :) ]

http://unity3d.com/unity/whats-new/unity-4.0#upgrade-guide

Comment
Add comment · Show 6 · 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 Fattie · Sep 25, 2013 at 08:15 AM 0
Share

@rob, thanks

(1) enabled is not just available on "Behaviour". It seems to be available on a randomly-unconneted list of items, for example click here to see some (but not all) of them:

http://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=enabled

(2) Rob I'm thinking the question becomes more specifically: was enabled ever available on component as such? or do I just have my head in ass as usual there? Do you happen to know?

(I thought it was once on "component" generally, and then they moved it down only to that "specific list of stuff" -- but maybe I'm plain totally wrong and it was only ever on that specific list of stuff... thoughts??)

thanks!!

avatar image robhuhn · Sep 25, 2013 at 08:40 AM 1
Share

1) Yes, it's not only available on behaviour because enabled is just a name for a property. This enabled and that enabled do different things - Just like Task.IsRunning and Human.IsRunning where the names are equal but the context is different. I guess I get you wrong somehow.

2) I don't know if it was a property of component in the past and actually I'm wondering why that's important because in any way you wouldn't need to refactor your code.

avatar image Bunny83 · Sep 25, 2013 at 08:48 AM 0
Share

Fattie was talking about other components, not about arbitrary classes with enabled ;). A common usecase would be to disable all components on a gameobject. However since Component doesn't have an enabled property you can't do this.

Of course there are components that can't be disabled (since it wouldn't make any sense like the Transform)

avatar image Fattie · Sep 25, 2013 at 08:52 AM 0
Share

(1) - totally got it now, thanks. indeed it's "just the same word". absolutely no OO-esque relationship

(2) well, I wanted to know if it ever was on component generally (answer - absolutely not) and I wanted to know how or if it at all it could be generalised (was there some thing X that all X has "enabled" - answer, absolutely not, it is sheer homograph.)

{I would possibly feel that, in program$$anonymous$$g, especially such a big API like Unity, it is a poor idea to have such a wholly-pro$$anonymous$$ent homograph, that has utterly no meaning whatsoever. I bet 95% of programmers from $$anonymous$$ars, glancing at slabs of Unity code, would assume that is an actual inherited property [perhaps from Component or Behaviour or even GameObject] rather than a pure utterly meaningless coincidental homograph. Anyway that's not relevant.}

Again thank you so much for the superb insight and explanation, cheers

avatar image Fattie · Sep 25, 2013 at 08:58 AM 1
Share

{Thus for example: you can find literally 100s of examples on this site or the internet, where, programmers either think that "enabled" is a property of something like Component, GameObject or Behaviour, and additionally generally confuse it with say SetActive (which relates only to gameobjects of course). Glancing around the internet, this confusion is very common, if not ubiquitous. Note too that in the inspector the checkbox for GameObject feels similar to the homograph-utterly-coincidental-no-relationship-in-any-way-amongst-themselves-"enabled"-checkboxes. So, it's clearly a topic ripe for confusion.}

{I personally had no clue, whatsoever, about any of this - at all. I would just thrash around clicking boxes, or in code randomly change between enabled, setActive, etc etc, until it seems to work and a client sends money :O Now, all is totally clear.}

In a word this question would probably be useful to many - now everyone will have the understanding you three guys already exhibit!

Show more comments

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

17 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

Related Questions

BCE0019: 'enabled' is not a member of 'UnityEngine.Component' when using List 1 Answer

.enabled Problems 1 Answer

enabled is not a member of UnityEngine.Component 1 Answer

Disable all components but 1 on a gameobject 1 Answer

Disabled script still working C# 3 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