Find current index of an array

I have a slider and an array of Gameobjects. When the slider changes, I want to disable the current gameObject and enable the corresponding gameObject.
I take the value of the slider and use it to enable the new gameObject but I dont know how to get the value of the current element array that is active. I can only find answers of how to get the value of the element itself, not the element index.
Ive been trying to also set that value to a new variable and use a few different things but I cant figure it out.
My code looks something like this.

public GameObject[ ] graphPoint;

public void UserSlide(){

int x=(int)sliderval.value;
graphPoint[×].SetActive(true);

}

you can either store the value in a global scope int each time you change it or you can use a for loop to disable every object in the array with the exception of the current x value.

1 Like