Hi, It’s since a week that I’ve this problem, in IEnumerator function, i get the error “Unexpected symbol”. I really hope that someone can Help me!
using System;
using UnityEngine;
public class LightAnimator : MonoBehaviour {
Coroutine lightOnCoroutine;
Coroutine lightOffCoroutine;
public Light[] lights;
public KeyCode controlKey = KeyCode.X;
private bool on = false;
void Start() {
}
void Update() {
if (Input.GetKeyDown (controlKey)) {
on = !on;
if (!on) {
lightOnCoroutine = StartCoroutine ("ChangeLight");
if(lightOffCoroutine != null) {
StopCoroutine(lightOffCoroutine);
}
}
if (on) {
lightOffCoroutine = StartCoroutine ("StopLight");
if(lightOnCoroutine != null) {
StopCoroutine(lightOnCoroutine);
}
}
}
IEnumerator ChangeLight() {
int i = 0;
while(true) {
lights*.enabled = false;*
i++;
if(i > lights.length - 1) {
i = 0;
}
lights*.enabled = true;*
yield return WaitForSeconds(1);
}
}
}
}