Actually I fixed this code again, only because what you wrote so thank you .
I put it in Update because when it was in Start the coroutine ran only once, but now I added a while loop around the foreach loop and it works fine when the StartCoroutine is in Start
public class Lights : MonoBehaviour
{
[SerializeField] Light[] mainWorldLight;
[SerializeField] float blinkWorldTime;
WaitForSecondsRealtime WaitBlinkWorldTime;
private void Awake()
{
WaitBlinkWorldTime = new WaitForSecondsRealtime(blinkWorldTime);
}
private void Start()
{
StartCoroutine(BlinkWorldLights());
}
IEnumerator BlinkWorldLights()
{
while (true)
{
yield return WaitBlinkWorldTime;
foreach (var light in mainWorldLight)
{
light.enabled = !light.enabled;
}
}
}
}