Renderer.isVisible
Declaration
public bool isVisible;Описание
Видимо ли это изображение на любой камере? (только для чтения)
Обратите внимание, что объект считается видимым, когда он должен быть отображен в Scene. Например, он может быть не видим для любой камеры, но все же должен быть отображен для теней. При запуске в редакторе, камеры просмотра Scene также приведут это значение к true.
Дополнительные ресурсы: OnBecameVisible, OnBecameInvisible.
//Attach this script to a GameObject with a Renderer component attached //If the GameObject is visible to the camera, the message is output to the console
using UnityEngine;
public class IsVisible : MonoBehaviour { Renderer m_Renderer; // Use this for initialization void Start() { m_Renderer = GetComponent<Renderer>(); }
// Update is called once per frame void Update() { if (m_Renderer.isVisible) { Debug.Log("Object is visible"); } else Debug.Log("Object is no longer visible"); } }