unity中自带两个回调函数:
void OnBecameVisible()//当物体可见时,回调一次。
void OnBecameInvisible()//当物体不可见时,回调一次。
在untiy编辑器中,无论调试窗口还是编辑窗口,只要能看到物体,OnBecameVisible都会被调用