Helle everyone!
I have GameController scrit wich sort all objects by initiative and change color active object.
How i can make script wich will wait for pressing a button before the next object to paint
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class GameController : MonoBehaviour
{
public bool active;
public List lst = new List(8);
public int SelIdx; // selected index
void Start()
{
active = true;
Stats[ ] stats = FindObjectsOfType(typeof(Stats)) as Stats[ ];
foreach (Stats stat in stats)
{
lst.Add(stat);
}
lst.Sort(delegate(Stats x, Stats y)
{
if (x.Initiative == y.Initiative) return 0;
else if (x.Initiative < y.Initiative) return 1;
else return -1;
});
SelIdx = 0;
lst[SelIdx].transform.renderer.material.color = Color.red;
StartCoroutine (“WaitAndChangeColor”);
}
IEnumerator WaitAndChangeColor()
{
while (active)
{
yield return new WaitForSeconds(0.5f);
lst[SelIdx].transform.renderer.material.color = Color.white;
SelIdx = (SelIdx + 1) % lst.Count;
lst[SelIdx].transform.renderer.material.color = Color.red;
}
}
}