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
4
Question by oleotiger · Nov 10, 2014 at 07:38 AM · gameobjectvisible

how to hide a GameObject?

I have two cameras----First Person camera and Third Person Camera. First Person camera is inside the model of a GameObject and the Third Person camera follows it. When I switch to the First Person camera, I see part of the model because the camera is inside of it. How can I hide the GameObject when I switch to the First Person camera? Is there some fuction like "GameObject.visible=false" or something else?

Please explain in details as I'm a beginner. Thank you very much!

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

3 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by GameVortex · Nov 10, 2014 at 08:41 AM

Disabling the GameObject is easy. You can quickly do that with the function SetActive:

 gameObject.SetActive(false);

This will however disable all components on the GameObject and any child GameObjects it has. You probably rather want to disable just the renderers. You are not giving a lot of details about your setup, but you are using either MeshRenderer or SkinnedMeshRenderer to render your player.

Search for the appropriate one and disable it by setting its enabled variable to false:

 MeshRenderer render = gameObject.GetComponentInChildren<MeshRenderer>();
 
 render.enabled = false;
Comment
Add comment · Show 7 · 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 oleotiger · Nov 10, 2014 at 09:48 AM 0
Share

The airplane model is made by "3ds max" and imported into unity. It's black in unity. Clicked on the model, there is no mesh property.

avatar image GameVortex · Nov 10, 2014 at 09:54 AM 0
Share

If you see a model, then there is always either a $$anonymous$$eshRenderer or a Skinned$$anonymous$$eshRenderer. If you do not see it on the gameObject, then it is on a child gameObject ins$$anonymous$$d.

avatar image oleotiger · Nov 10, 2014 at 09:57 AM 0
Share

The airplane model is made by "3ds max" and imported into unity. It's black in unity. Why? And how can I colour it?

PS:Clicked on the model, there is no renderers property. Is it need to be added manually?

avatar image GameVortex · Nov 10, 2014 at 10:11 AM 0
Share

The renderers are not a property, they are components on the GameObject. The model in the project view is not the gameobject. Your player is most likely a Prefab GameObject.

avatar image Scribe · Nov 10, 2014 at 12:58 PM 1
Share

Alternatively, in 3ds max, you could merge all the objects into one, then on import there would only be one model which you can turn the meshRenderer off for!

Show more comments
avatar image
0

Answer by simixd4 · Feb 01, 2021 at 06:31 AM

The airplane model is made by "3ds max" and imported into unity. It's black in unity. Why? And how can I colour it?

Because you don't have material, you need to add material to have a color

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 Zejak · Aug 31, 2021 at 08:52 AM

The thing that worked for me was just setting a parent object's scale to zero. This will "hide" any object that is under that parent and you don't have to worry about disabling any components.

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 simiel7 · Aug 31, 2021 at 08:11 PM 0
Share

But this will not disable the game object itself, which means it will be called, calculated and used no matter that the scale is 0. The child game objects will be called also and all of the components they have.
So if you planning to "hide" for example hundreds or thousands of game objects like this, the game still consume CPU time despite you cannot see them and it is not perfomance-wise solution.
Of course, if you use once in a while it can be acceptable, but probably the implementation behind the code that needs these kind of "hacks" are not planned correctly (no offense, just a constructive criticism).

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

30 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 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

What is the fastest way to activate or hide/show many gameobjects? 1 Answer

My GameObject isnt showing up in Scene nor in Game 1 Answer

How can I make a gameobject partially invisible by distance? 2 Answers

Hide gameobject until certain condition has been met,Hide an object until a condition is met. 2 Answers

How do I check if a GameObject is visible by a camera? 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