MonoBehaviour.OnBecameInvisible()

Switch to Manual

Description

OnBecameInvisible 在渲染器对任何摄像机都不可见时调用。

该消息将发送到附加到渲染器的所有脚本。 OnBecameVisibleOnBecameInvisible 有助于避免仅在对象可见时才需要进行的计算。

// Disables the behaviour when it is invisible

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { void OnBecameInvisible() { enabled = false; } }

OnBecameInvisible can be a co-routine, simply use the yield statement in the function. When running in the editor, Scene view cameras will also cause this function to be called.