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 Theacesofspades · Jun 22, 2014 at 01:04 AM · c#camerarendererenabled

Why isnt renderer.isVisible not working?

the script i have is:

 void Update ()
 {
     bool isVisible = renderer.isVisible;
 
     if (isVisible)
     {
         renderer.enabled = true;
     }else{
         renderer.enabled = false
     }
 }

my question is, How come this script isnt working?

Comment
Add comment · Show 1
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 Kiwasi · Jun 22, 2014 at 03:07 AM 0
Share

The biggest question I have is why. What effect are you trying to achieve?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by robertbu · Jun 22, 2014 at 02:43 AM

Thoughts:

  • Unity already does this kind of culling, so all you are doing is adding more overhead.

  • Any object with the renderer turned off is not considered visible even when it is in the view area of any camera.

  • Note isVisible is true when seen from any camera. Back in 3.x days that included the scene camera when in the Editor. That may still be true.

Comment
Add comment · Show 11 · 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 Theacesofspades · Jun 22, 2014 at 02:51 AM 0
Share

So do you have any ideas on how I can accomplish turning on and off the renderers if they are in view?

avatar image Eric5h5 · Jun 22, 2014 at 03:00 AM 0
Share

@theacesofspades: Don't bother. There's no reason to do this. Your script can't possibly work anyway because you turned the renderer off when not visible, so it would never turn back on again. Even if it could, polling .isVisible every frame isn't very efficient when you could use OnBecameVisible and OnBecameInvisible.

avatar image Theacesofspades · Jun 22, 2014 at 02:38 PM 0
Share

Ok but I used on became invisible and on became visible but how can I hide the objects that are not seen by camera? Because the game is too laggy since I have a ton of objects in the scene.

avatar image Eric5h5 · Jun 22, 2014 at 03:54 PM 1
Share

Unity already hides objects that are not seen. You don't have to do anything. If the game is laggy because you have too many objects, then reduce the number of objects. That's a completely separate issue.

avatar image robertbu · Jun 22, 2014 at 04:57 PM 1
Share

$$anonymous$$inecraft-line games use voxels. That is they construct many cubes using a single mesh. Using separate game object for each cube will kill your frame rate. Lots of posts on UA on voxels.

Show more comments

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

22 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

Related Questions

How can I stop the drawcall of an object if it is not in view of the camera, without using occlusion culling? 1 Answer

Renderer on object disabled after level reload 1 Answer

camera.enabled = true not working? 0 Answers

Checking if GameObject is rendered by specific camera 1 Answer

Multiple Cars not working 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