Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Marvin1960 · Oct 20, 2016 at 07:57 PM · gameobjectsdisableactivate

Oh the HUMANITY!! How do I deactivate one game object and then activate another?

Here's my issue. I'm making a game that requires something that I cannot find on the forums, the Unity manual or on YouTube. I have the need to be able to have many GameObjects that all have scripts. What I need to do is use my mouse to click on the object in game mode and deactivate it. Then, click on a different game object in game mode and activate that one, and back and forth, or have them all activated at one time. I know there must be a way to accomplish this. I'm fairly new to C# and I'm going nuts with this one. "Driving" objects around is no issue as there's a zillion ways to do it. I don't want to use collisions to perform this task, just simple mouse clicks.

Comment
Add comment · Show 5
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 Jessespike · Oct 20, 2016 at 08:19 PM 1
Share

Why no colliders? Is there a good reason?

avatar image andzq · Oct 20, 2016 at 08:38 PM 0
Share
        void On$$anonymous$$ouseDown()
     {
             gameObject.SetActive(false);
     }

Attach this to the gameobject you want to disable. Once disabled you cannot click it anymore though (obviously)

You might however just disable the mesh-renderer so the collider is still reacting to your clicks.

avatar image andzq · Oct 20, 2016 at 08:39 PM 0
Share

U gotta set the colliders on the objects to trigger btw

avatar image Marvin1960 · Oct 21, 2016 at 01:20 PM 0
Share

Thanks andzq! The reason I don't want to use colliders is that I don't wish to have the need to bump into them for deactivate / activate. $$anonymous$$ouse click is the preferred method if possible. Regarding your mention of disabling the mesh-renderer, will this have the same effect as the on$$anonymous$$ouseDown but still be reversible to activate the object again later on?

avatar image andzq · Oct 21, 2016 at 06:06 PM 0
Share

if you only disable the mesh renderer the gameobject and it's colliders/triggers will still be active and will respond to On$$anonymous$$ouseDown - yes.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Marvin1960 · Oct 21, 2016 at 07:13 PM

ZWEEEET! Thank you for the information!!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Cannot deactivate / activate gameobject, even in editor! 6 Answers

Is there any command that can reference deactivated objects? 1 Answer

Activate/deactivate all GameObjects with same tag c# 1 Answer

How do I enable and disable multiple game objects in Unity? 1 Answer

How to disable all objects but... 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