How to apply switch case on the button to activate and deactivate game object?

//Collect the game object
public GameObject sorting;

 //Collect the button
 public GameObject[] sortingBtn;
 int j;
 int b;

void Start () {
        sorting = GameObject.FindGameObjectsWithTag("Sort");
        sortingBtn = GameObject.FindGameObjectsWithTag("SortButton");

        for (j = 0; j < sorting.Length; j++)
        {
            Debug.Log(j + " " + sorting[j].name);
        }
        for (b = 0; b < sortingBtn.Length; b++)
        {
            Debug.Log(b + " " + sortingBtn**.name);**

}
Invoke(“CurrentScene”, 1);
}

public void CurrentScene()
{
switch (b)
{
case 1:
Debug.Log(“Plastic hellooo”);
sorting[1].SetActive(true);
sorting[0].SetActive(false);
break;
case 0:
Debug.Log(“Paper hellooo”);
sorting[0].SetActive(true);
sorting[1].SetActive(false);
break;
default:
Debug.Log(“Default hellooo”);
sorting[0].SetActive(true);
sorting[1].SetActive(false);
break;
}
}
The case default works well at the beginning. But when click the UI button to switch the case it doesn’t work.
How to make the button respond to the condition that has be set in switch case statement? (The button had been attached with pubic void CurrentScene in Unity).

//Collect the game object
public GameObject sorting;
//Collect the button
public GameObject sortingBtn;
int j;
int b;

 void Start () {
         sorting = GameObject.FindGameObjectsWithTag("Sort");
         sortingBtn = GameObject.FindGameObjectsWithTag("SortButton");
 
         for (j = 0; j < sorting.Length; j++)
         {
             Debug.Log(j + " " + sorting[j].name);
         }
         for (b = 0; b < sortingBtn.Length; b++)
         {
             Debug.Log(b + " " + sortingBtn**.name);**

Button btn = sortingBtn**.GetComponent();**
btn.onClick.AddListener(() => Currentscene(b));
}
Invoke(“CurrentScene”, 1);
}

public void CurrentScene(int buttonnumber)
{
switch (buttonnumber)
{
case 1:
Debug.Log(“Plastic hellooo”);
sorting[1].SetActive(true);
sorting[0].SetActive(false);
break;
case 0:
Debug.Log(“Paper hellooo”);
sorting[0].SetActive(true);
sorting[1].SetActive(false);
break;
default:
Debug.Log(“Default hellooo”);
sorting[0].SetActive(true);
sorting[1].SetActive(false);
break;
}
}
this should do the trick. if button is not available, put: using UnityEngine.UI; at the top of the file.

I guess u need to send the butonNumber parameter on buttonClick, on the basis of which switch case will work.113491-capture.png