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
0
Question by andy-go · Jul 21, 2012 at 11:46 PM · gameobjectmeshvisiblefalse

Problems with Game object visible when active is false

Hi,

I'm a newbie to unity so this might be a basic problem but I can't find a solution.

I've a public game object var with the script "name.active = false".

When I attach a simple mesh to this var, it works perfectly (I want it to be invisible and inactive). But when it's a mesh within a game object it's inactibe but still visible.

If someone can help.

Thanks

Comment
Add comment · Show 6
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 blitzen · Jul 21, 2012 at 11:49 PM 0
Share

Could you clarify a bit why you're making the name inactive, and not the GameObject?

Also, I'm not sure what you mean by attaching a mesh to the "var". A mesh is attached to a $$anonymous$$eshFilter component of a GameObject, and if that GameObject's "active" property is set to "false", it'll be made invisible. Perhaps you have a mesh attached to a child object in its hierarchy?

avatar image andy-go · Jul 22, 2012 at 08:37 AM 0
Share

About the name, it's the name of the public var. Like this I declare public GameObject $$anonymous$$emory1; and later $$anonymous$$emory1.active = false;

I indeed had a problem in my hierarchy. Thank you !!!

And by the way I guess it is not possible so to make inactive and invisible a child object by deactivating the parent?

avatar image Seth-Bergman · Jul 22, 2012 at 08:57 AM 0
Share

for that you can use:

GameObject.SetActiveRecursively

edit:

as in gameObject.SetActiveRecursively(false); // to turn off

avatar image andy-go · Jul 22, 2012 at 09:48 AM 0
Share

Thanks, this is really going to help me.

avatar image Bovine · Jul 22, 2012 at 11:35 AM 0
Share

SetActiveRecursive() can be expensive, so avoid doing it every frame, or at least, avoid doing it every frame to lots of objects, especially if you're targeting mobile.

If you need to do this sort of thing and the hierarchy of the Transform you're enabling/disabling is fixed, you're better to create a script that discovers and caches the hierarchy, so that you can iterate over each GameObject in that hierarchy and set it it directly, ins$$anonymous$$d of finding each item every time.

I suspect SetActiveRecursively() is doing a lot of GetComponent() and then looping over children etc... etc...

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by andy-go · Jul 24, 2012 at 12:57 PM

Ok I don't think i'll be using it too much so it should be ok. Thanks.

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
avatar image
0

Answer by andy-go · Jul 24, 2012 at 12:57 PM

OK I don't know exactly how it is going to work so I'll try this way to begin with (it looks easier to begin). And if I meet problem, I'll try your method. Thanks

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problems with save 1 Answer

How to use if statement properly 1 Answer

Instantiated GameObject Not Rendering 1 Answer

It's possible save materials and meshes into a prefab like the unity's model importer? 2 Answers

I want some gameobjects are all unactive! 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