public class Ball:MonoBehaviour{ void OnBecameInvisible(){ Destroy(this.gameObject); } }
OnBecameInvisible函数会在游戏对象移动到画面之外时调用的方法。