Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 cinqrouge · May 30, 2017 at 05:03 PM · rendererisvisible

Render.IsVisible always show visible even when off camera.

Hi!

This is my code, it is not working yet. I'm trying to tell if the children of the component of the children is visible or not but the Renderer always tells me that it is visible in the Debug.Log.

I also check if it was looking at the right Renderer which he seems to be doing.

In the end I want to run code when the children of the gameobject became invisible. If you have a better idea how to let me know !

Thanks and have a nice day! :)

 public class teleport2 : MonoBehaviour {
 
     public Renderer mesh;
 
     // Use this for initialization
     void Start () {
         mesh = GetComponentInChildren<Renderer>();
         
     }
     
     // Update is called once per frame
     void Update () {
         Debug.Log(mesh.isVisible);
         Debug.Log(mesh.name);
 
     }
 
     private void OnBecameInvisible()
     {
         var cam = Camera.main;
         var viewportPosition = cam.WorldToViewportPoint(transform.position);
         var newPosition = transform.position;
 
         if (viewportPosition.x >1 || viewportPosition.x < 0)
         {
             newPosition.x = -newPosition.x;
         }
 
         if (viewportPosition.y > 1 || viewportPosition.y < 0)
         {
             newPosition.y = -newPosition.y;
         }
 
         transform.position = newPosition;
 
     }
 }

alt text

question-onvisible.png (64.9 kB)
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
3
Best Answer

Answer by HenryStrattonFW · May 30, 2017 at 06:10 PM

One thing to keep in mind here is that the scene view is still rendering an object through a camera, which will cause the isVisible property to return true if it is considered visible in any game or scene view.

Try closing your scene view or full-screen your game view to test, if this fixes the problem then you just have to make sure that when you test, either deactivate your scene view or move the scene view camera.

Comment
Add comment · Show 2 · 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 Nanobrain · Oct 24, 2019 at 03:58 PM 0
Share

Wow. Good to know. I've never realized this before. Thanks @HenryStrattonFW...over 2 years later!

avatar image Pangamini · Oct 24, 2019 at 04:54 PM 0
Share

Objects are also 'visible' by shadow casting lights, right?

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

6 People are following this question.

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

Related Questions

Render.IsVisible returning false for one frame 2 Answers

renderer.is(Completely)Visible? 1 Answer

check if children are visible, if not destroy parent? 1 Answer

renderer.isVisible problem on prefab 3 Answers

C# Renderer.IsVisible counts when editor camera sees object 0 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