Я пытаюсь сделать игру вождения в Unity, и как часть этого, я пытаюсь заставить светофор мигать и выключаться.
Это мой сценарий, к которому я прикрепилсветофор.Иерархия светофора:
TrafficLight_A (базовый светофор)
- RedLight (свет, который я пытаюсь сделать вспышкой)
using UnityEngine;
using System.Collections;
public class Blink_Light : MonoBehaviour
{
public float totalSeconds = 2; // The total of seconds the flash wil last
public float maxIntensity = 8; // The maximum intensity the flash will reach
public Light myLight = Light RedLight; // The light (error)
public IEnumerator flashNow ()
{
float waitTime = totalSeconds / 2;
// Get half of the seconds (One half to get brighter and one to get darker)
while (myLight.intensity < maxIntensity) {
myLight.intensity += Time.deltaTime / waitTime; // Increase intensity
yield return null;
}
while (myLight.intensity > 0) {
myLight.intensity -= Time.deltaTime / waitTime; //Decrease intensity
yield return null;
}
yield return null;
}
}
Однако я получаю сообщение об ошибке:
Assets/Blink_Script/Blink_Light.cs: error CS1525: Unexpected symbol "RedLight"
Что я могу сделать, чтобы это исправить?(Я немного новичок в C#
)