У меня есть игра Unity3D, в этой игре есть игра, похожая на iMimic.
Проблема здесь в том, что весь код работает отлично, но в нем есть детали,
игра запускается в следующем порядке:
, (как видите, все вместе), но мне нужно, чтобы она работала так: ![enter image description here](https://i.stack.imgur.com/bsq9z.gif)
Может быть, это деталь цикла foeach? Или IEnumerators?
void Randomizer()
{
PreList = PreList.OrderBy(C => Rnd.Next()).ToArray();
foreach (var item in PreList)
{
Debug.Log(item.ToString());
if (item == 1)
{
StartCoroutine(OneMethod());
}
if (item == 2)
{
StartCoroutine(TwoMethod());
}
if (item == 3)
{
StartCoroutine(ThreeMethod());
}
}
IEnumerator OneMethod()
{
ButtonList.Add(1);
GameObject.Find("Red").GetComponent<Image>().color = Color.gray;
//Sound
yield return new WaitForSeconds(1);
GameObject.Find("Red").GetComponent<Image>().color = Color.white;
Debug.Log("Everyone");
yield return new WaitForSeconds(1);
}
IEnumerator TwoMethod()
{
ButtonList.Add(2);
GameObject.Find("Blue").GetComponent<Image>().color = Color.gray;
yield return new WaitForSeconds(1);
GameObject.Find("Blue").GetComponent<Image>().color = Color.white;
Debug.Log("Everyone");
yield return new WaitForSeconds(1);
}
IEnumerator ThreeMethod()
{
ButtonList.Add(3);
GameObject.Find("Green").GetComponent<Image>().color = Color.gray;
yield return new WaitForSeconds(1);
GameObject.Find("Green").GetComponent<Image>().color = Color.white;
Debug.Log("Everyone");
yield return new WaitForSeconds(1);
}