OnBecameVisible 在渲染器变为对任意摄像机可见时调用。
该消息将发送到附加到渲染器的所有脚本。 OnBecameVisible 和 OnBecameInvisible 有助于避免仅在对象可见时才需要进行的计算。
// Enables the behaviour when it is visible
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void OnBecameVisible() { enabled = true; } }
OnBecameVisible 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.