im having a little trouble with my array, im not going to lie i havent used them allot which is why im struggling a little so any help or correctons to my code will be loved.
public GameObject[] moonRock;
void Start ()
{
for(int i = 0; i <= moonRock.Length; i++)
{
Debug.Log(moonRock[i].name);
int s = 1;
if(PlayerPrefs.GetInt("MoonRock " + s.ToString()) == 1)
{
moonRock[i].SetActive(false);
}
else
{
moonRock[i].SetActive(true);
}
s++;
}
}
}
basicly this script is to turn an image gameobject of with text in it which is why im using gameobject not image.
my player prefs start at 1 like “MoonRock 1”
and the array starts at 0 up to 13 at the moment
the array works but only if the first moonrock is there and when the moonrock is there it turns all gameobjects of in the array




