Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Mattivc · Aug 13, 2010 at 01:56 AM · cameragameobjectrendering

Check if object is being rendered

Is there a way to check if a object is within any cameras render area?

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

5 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by qJake · Aug 13, 2010 at 02:14 AM

renderer.isVisible

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
4

Answer by jtbentley · Sep 07, 2010 at 01:42 PM

Yes! I don't know how often you'd want to check it, but if you want it per frame..

var objectToStalk : GameObject; private var objectToStalkRenderer : Renderer; // Cache this so its faster

function Start() { objectToStalkRenderer = objectToStalk.renderer; // This reduces a get_component call in the update loop }

function Update() { if (objectToStalkRenderer.isVisible) print ("Jessica Alba is hot."); }

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 tomka · Jun 06, 2012 at 11:00 AM 1
Share

Brilliant answer.

avatar image Elmar1498 · Feb 22, 2013 at 08:32 AM 0
Share

Should I attach a script on the player

avatar image
1

Answer by ThatOwlGuy · Jan 03, 2017 at 07:33 AM

Note that the object is considered visible when it needs to be rendered in the scene. For example, it might not actually be visible by any camera but still need to be rendered for shadows. When running in the editor, the scene view cameras will also cause this value to be true.

from --> https://docs.unity3d.com/ScriptReference/Renderer-isVisible.html

(Just in case anyone's still looking for this solution)

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
1

Answer by nathaxx · Jul 27, 2021 at 12:47 PM

sorry for wakening an old thread, but in case a newbie stumbles upon this:

Nowadays it should be called gameObject.GetComponent<Renderer>.isVisible .

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 VRKeith · Feb 06 at 03:08 AM 0
Share

The GOAT. I could tell this was on old question by one of the comments referencing Jessica Alba.

avatar image
0

Answer by cristian-chidean · Apr 21 at 02:53 PM

If you are using a Screen Space Canvas, you can check with this script:

 using UnityEngine;
 
 public class VisibleTest : MonoBehaviour
 {
     RectTransform rect;
     Rect screenBounds = new Rect(0f, 0f, Screen.width, Screen.height);
 
     void Start()
     {
         rect = GetComponent<RectTransform>();
     }
 
     void Update()
     {
         Debug.Log(IsVisible());
     }
 
     public bool IsVisible()
     {
         Vector3[] corners = new Vector3[4];
         rect.GetWorldCorners(corners);
 
         for (var i = 0; i < corners.Length; i++)
         {
             if (screenBounds.Contains(corners[i]))
             {
                 return true;
             }
         }
 
         return false;
     }
 }
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

6 People are following this question.

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

Related Questions

Have Camera Render First Person Arms But Not Body. 2 Answers

GameObject can disappear 1 second after play, but still appear in scene window 1 Answer

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

cameras rendering problem 4 Answers

Capture a (screen shot) scene shot with alpha 2 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