//创建目标组件 public GameObject tarGet; //时刻检测用户状态 private void Update() { //如果鼠标左键点击了 if (Input.GetMouseButtonDown(0)) { //控制台输出信息,大多用于调试 Debug.Log("左键点击了"); //获取目标物体的SecondController组件 SecondController control = tarGet.GetComponent<SecondController>(); //停用SecondController组件 control.enabled = false; } }