mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 05:50:18 +00:00
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:
parent
6bbdcecd7d
commit
fe4ae08ca6
1 changed files with 14 additions and 8 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue