I have a public array full of Images from the inspector. A method runs which for 6 iterations, should generate a random number which links to an index in the array and makes that image visible.
When I run the program however, nothing actually happens, all images remain invisible. Can anyone identify the issue?
This is my code:
public class CoinDecider : MonoBehaviour {
public Image[] Images; //array of images, assigned through inspector
public void Start()
{
//for 6 iterations, a random number between 1 and 16 is generated
//that number is assigned to the index of one of the images
//said image becomes visible
for (int i = 0; i < 6; i++)
{
int number = Random.Range(1, 16);
var selected = Images[number];
selected.enabled = true;
}
}
}
Just for extra insurance, this is what the list from the inspector looks like (all images are placed on screen but defaulted to invisible at the start of the game):
Aucun commentaire:
Enregistrer un commentaire