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
3
Question by Fusobotic · Jun 26, 2010 at 08:33 PM · gameobjectdisabletagsenabled

Enabling/Disabling Multiple Tagged objects

I'm having a little trouble trying to disable some objects through a level controller script. Basically I've tagged multiple objects with the tag "zones" (they're triggers) and I want to disable all of them through a single controller script. Whenever I tried stating a var and then containing all the gameobjects within it with the "FindGameObjectsWithTag()" it didn't work, then I tried doing it in one line of code instead:

GameObject.FindGameObjectsWithTag("zones").enabled = false;

Any suggestions? It returns an error : "enabled is not a part of UnityEngine.GameObject", with both techniques. btw, I'm using the the line of code inside of an Update function.

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
6
Best Answer

Answer by Mike 3 · Jun 26, 2010 at 09:14 PM

That's because it's returning a gameobject array, not a single gameobject (and on top of that, it's active for gameobjects, not enabled)

you can do something like this:

for(var go : GameObject in GameObject.FindGameObjectsWithTag("zones"))
{
    go.active = false;
}
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 Fusobotic · Jun 26, 2010 at 10:25 PM 0
Share

So this'll work if I just cut & paste? Or do I have to rename a few things, or change something in a different area of script?

avatar image Mike 3 · Jun 26, 2010 at 10:41 PM 0
Share

It should just work pretty much anywhere (within reason - it has to be compilable ;) )

avatar image Orggrim · May 24, 2013 at 08:13 AM 0
Share

I would like to note $$anonymous$$ike3 that you just solved my Camera Array problem!!!!! TY TY TY TY TY TY TY

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

1 Person is following this question.

avatar image

Related Questions

Information about Behaviour.enabled 1 Answer

Errors when trying to enable script on gameobject. 0 Answers

Disable a script on another game object 2 Answers

Disalbe/Activate script if a key is pressed. 1 Answer

gameObject.GetComponent("Script").enabled = true not working 5 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