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
2
Question by YoshieMaster · Dec 30, 2010 at 01:40 AM · activeenabled

Disable Object Leave Script Running

Hi Everyone, I would like to have an object disabled for 5 seconds. I used the following JS: gameObject.active = false; yield WaitForSeconds(5); gameObject.active = true; But it seems that the script stops running as soon as active is set to false. Could someone please confirm this or is it just some other bug in my script. Also, setting the gameObject to inactive for some reason isn't making my object invisible. The models (there are 2) for my object are children of it so I don't get why the renderers aren't being disabled. I also tried doing gameObject.Find("MiniMap Icon").renderer.enabled = false; but that returned an error about no renderer being attached to gameObject MiniMap Icon. One last thing, if the script stops running immediately when gameObject.active is set to false, could someone suggest a way to reenable it after 5 seconds please?

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

1 Reply

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

Answer by Eric5h5 · Dec 30, 2010 at 02:11 AM

Yes, the point of a deactivated object is that it's not active (no rendering, scripts running, etc.). Making an object inactive only makes that object inactive, not children, which are separate objects. You can use GameObject.SetActiveRecursively for that. If you get an error about no renderer attached, that means exactly what it says (that object has no renderer), so use a different object that does have a renderer. You can re-enable inactive objects from a different object that's not inactive.

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 fireDude67 · Jan 06, 2011 at 03:51 AM 0
Share

Thanks, never knew about SetActiveRecursively()!

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

No one has followed this question yet.

Related Questions

.enabled does not enabled GUItexture 1 Answer

Enabling/Disabling components disabling my GameObject? 1 Answer

unity 2d trigger a script with a trigger? 0 Answers

Button to create object??? 1 Answer

script wont re activate object when my conditions are met 1 Answer


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