using System.Collections; using UnityEngine; using UnityEngine.UI; namespace NextMind.Examples.Calibration { /// /// This component is used to make an Image switch between two colours following time parameters. /// It used for to animate the LED elements on pairing instructions schemes. /// [RequireComponent(typeof(Image))] public class SchemeLedBlinker : MonoBehaviour { [SerializeField] private float waitBetweenBlinks; [SerializeField] private float blinkDuration; [SerializeField] private Color onColor; [SerializeField] private Color offColor; private Image image; // Start is called before the first frame update void Start() { image = GetComponent(); StartCoroutine(Blink()); } // Update is called once per frame private IEnumerator Blink() { while (true) { image.color = offColor; yield return new WaitForSeconds(waitBetweenBlinks); image.color = onColor; yield return new WaitForSeconds(blinkDuration); } } } }