using UnityEngine; // 批量控制某些go的显示和隐藏 public class HasControl : MonoBehaviour { public bool hasControl = true; public GameObject[] objectsToRemove;//MainCamera ScreenShake private void Awake() { UpdateControl(); } private void UpdateControl() { GameObject[] array = objectsToRemove; foreach (GameObject gameObject in array) { gameObject.SetActive(hasControl); } } public void ChangeControl(bool control) { hasControl = control; UpdateControl(); } }