I have a memory game and I have two for loops (picture and word). I looked up the another randomly pick questions but I could not solver because I have two for loops. How can i do this?
An array has 16 elements. First 8 elements has pictures, Last 8 elements has 8 words. according to this array, I have to pick randomly 6 elements.
for (int i = 0; i < cardCollection4x3.Count; i++)
{
int n = i - 4;
if (cardCollection4x3[i].childCount > 1)
{
cardCollection4x3[i].GetComponentInChildren<UnityEngine.UI.Text>().text = questionData.answer[n].ToUpper();
}
}
for (int i = 0; i < questionData.answer.Length - 8; i++)
{
if (cardCollection4x3[i].name.Contains("Fish"))
{
cardCollection4x3[i].GetComponent<UnityEngine.UI.Image>().sprite = Resources.Load<Sprite>(questionData.answer[i]);
}
}
Aucun commentaire:
Enregistrer un commentaire