Version: 2022.2
언어: 한국어
public bool isVisible ;

설명

Is this renderer visible in any camera? (Read Only)

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.

See Also: 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"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961