I am currently making a pause menu and I have some gameobjects with colliders being instantiated. When the game is paused, I want the colliders to not respond to click.
I have tried changing the layer to “Ignore Raycast” which works but it only works for one gameobject at a time since I have no idea how to implement a SetLayerRecursively function.
What would be best for me to disable the colliders during runtime with script?`
public GameObject pausePanel, resumeButton, pauseButton, aobdt;
public void Start(){
OnUnpause ();
}
public void OnPause(){
pausePanel.SetActive (true);
pauseButton.SetActive (false);
aobdt.SetActive (false);
Time.timeScale = 0;
Debug.Log ("Game has been paused");
//This part only disables the first number that comes on
//I need to make it in a way so that it changes the layer for each and every one of them
GameObject.FindWithTag ("Numbers").layer = LayerMask.NameToLayer("Ignore Raycast");
Debug.Log (GameObject.FindWithTag ("Numbers").layer);
}
public void OnUnpause(){
pausePanel.SetActive (false);
pauseButton.SetActive (true);
aobdt.SetActive (true);
Time.timeScale = 1;
Debug.Log ("Game has resumed");
GameObject.FindWithTag ("Numbers").layer = LayerMask.NameToLayer("Default");
Debug.Log (GameObject.FindWithTag ("Numbers").layer);
}
`