Manually set the traffic light crossing state. The crossing will change instantly to the new color.
Declaration
public static void SetTrafficLightsCrossingState(string crossingName, TrafficLightsColor newColor, bool stopUpdate= false)
Parameters
Name
Description
crossingName
The name of the street crossing.
newColor
the new color to change into.
stopUpdate
Stop crossing from automatically changing colors from now on.
Example
using Gley.TrafficSystem;
using UnityEngine;
public class Test : MonoBehaviour
{
private void Update()
{
if(Input.GetKeyDown(KeyCode.Z))
{
// Change crossing to red and keep automatic lights changing.
API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.Red);
}
if (Input.GetKeyDown(KeyCode.X))
{
// Change crossing to yellow and keep automatic lights changing.
API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.YellowRed,false);
}
if (Input.GetKeyDown(KeyCode.C))
{
// Change crossing to red and keep red until new color is manually set.
API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.Red, true);
}
}
}