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 /
This question was closed Jan 14, 2015 at 03:19 PM by unimechanic for the following reason:

Duplicate Question

avatar image
0
Question by DrakeDiablo · Jan 10, 2015 at 08:13 PM · rendererenablevisible

OnBecameVisible is not working correctly!

Hi! I want to make a script where if the camera is facing an object, that object needs to become visible or enabled, and if im not facing it, it should get disabled or something. function OnBecameVisible only works if the mesh renderer on that object is enabled, that defeats the purpose of that script. How do I make a script that enables/disables the object if its visible, no matter if its disabled or enabled already? Thanks!

For this script I disabled the mesh renderer in the editor, and its not working :/

 #pragma strict
 
 var visible : boolean =false;
 
 function Start () {
 
 }
 
 function Update () {
     if(visible ==true){
         renderer.enabled = true;
     }
 }
 
 function OnBecameVisible() {
     visible = true;
 }
Comment
Add comment · Show 3
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 Eric5h5 · Jan 10, 2015 at 09:04 PM 0
Share

It's working 100% correctly. If you disabled the renderer, there's no way OnBecameVisible can fire. Also, even if the logic made any sense, why would you constantly poll a variable in Update when you could just do the work in OnBecameVisible?

avatar image DrakeDiablo · Jan 10, 2015 at 10:08 PM 0
Share

I am just trying to make a script that unity pro has but unity free doesnt. If I am facing a bunch of objects, they will be all rendered, but I want to make it so if some smaller object is behind a bigger object, i want the smaller object to be disabled so it doesnt use up draw calls.

avatar image Eric5h5 · Jan 10, 2015 at 10:25 PM 0
Share

That won't work at all. An object going behind another one doesn't make it invisible. It's still there and perfectly visible, just covered up by objects drawn on top. If you're trying to replicate occlusion culling, you'd have to manually create your own system (which does not involve OnBecameVisible in any way; maybe raycasting or something).

1 Reply

  • Sort: 
avatar image
0

Answer by unimechanic · Jan 14, 2015 at 03:18 PM

http://answers.unity3d.com/questions/215704/creating-custom-occlusion-culling.html

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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Detect if entity is visible - renderer.isvisible will not work! 3 Answers

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

Problem is "renderer.isVisible" 3 Answers

If gameObject is invisible - disable it... what's wrong with this code? 1 Answer

Hiding objects between my character and camera, how to show them again when they're no longer in the way? 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