display radio station label for limited amount of time - 3 seconds after ped enters vehicle or radio station is changed

This commit is contained in:
in0finite 2020-05-07 18:22:42 +02:00
parent 6bbdcecd7d
commit fe4ae08ca6

View file

@ -23,6 +23,8 @@ namespace SanAndreasUnity.UI {
public Text radioStationText;
public RawImage radioStationImage;
[SerializeField] [Range(0.3f, 10f)] float m_radioStationLabelDuration = 3f;
public static Texture2D LeftArrowTexture { get; set; }
public static Texture2D RightArrowTexture { get; set; }
public static Texture2D UpArrowTexture { get; set; }
@ -152,19 +154,23 @@ namespace SanAndreasUnity.UI {
this.pedVelocityText.text = pedVelocityDisplayText;
}
string textForRadioStation = "";
var vehicle = ped.CurrentVehicle;
if (vehicle != null)
{
string text = vehicle.CurrentRadioStationIndex >= 0 ? RadioStation.StationNames[vehicle.CurrentRadioStationIndex] : "Radio Off";
if (this.radioStationText.text != text)
this.radioStationText.text = text;
}
else
{
if (this.radioStationText.text != "")
this.radioStationText.text = "";
var seat = ped.CurrentVehicleSeat;
if (vehicle.TimeSinceRadioStationChanged < m_radioStationLabelDuration
|| (seat != null && seat.TimeSincePedChanged < m_radioStationLabelDuration))
{
textForRadioStation = vehicle.CurrentRadioStationIndex >= 0 ?
RadioStation.StationNames[vehicle.CurrentRadioStationIndex] : "Radio Off";
}
}
if (this.radioStationText.text != textForRadioStation)
this.radioStationText.text = textForRadioStation;
}
}