//定义运行区域为屏幕,如果鼠标出屏幕则停止运行 Rect screenRect = new Rect(0,0,Screen.width,Screen.height); if( !screenRect.Contains(Input.mousePosition)) return;