| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using UnityEngine; |
| | | 4 | | |
| | | 5 | | public class TrafficLights : MonoBehaviour |
| | | 6 | | { |
| | | 7 | | public Light Red; |
| | | 8 | | public Light Green; |
| | | 9 | | public Light Yellow; |
| | | 10 | | |
| | | 11 | | |
| | | 12 | | |
| | | 13 | | // Start is called before the first frame update |
| | | 14 | | IEnumerator Start() |
| | 2 | 15 | | { |
| | 2 | 16 | | Yellow.enabled = false; |
| | | 17 | | |
| | 2 | 18 | | while (true) |
| | 2 | 19 | | { |
| | 2 | 20 | | Green.enabled = true; |
| | 2 | 21 | | Red.enabled = false; |
| | 2 | 22 | | yield return new WaitForSeconds(30); |
| | 0 | 23 | | Debug.Log("on"); |
| | 0 | 24 | | Yellow.enabled = true; |
| | 0 | 25 | | Green.enabled = false; |
| | 0 | 26 | | yield return new WaitForSeconds(5); |
| | 0 | 27 | | Debug.Log("on"); |
| | 0 | 28 | | Red.enabled = true; |
| | 0 | 29 | | Yellow.enabled = false; |
| | 0 | 30 | | yield return new WaitForSeconds(30); |
| | | 31 | | |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | |
| | | 37 | | // Update is called once per frame |
| | | 38 | | void Update() |
| | 67 | 39 | | { |
| | | 40 | | |
| | 67 | 41 | | } |
| | | 42 | | } |