mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
display current time in UI
This commit is contained in:
parent
197089aab3
commit
f72cd743a3
3 changed files with 100 additions and 0 deletions
|
@ -1139,6 +1139,85 @@ MonoBehaviour:
|
|||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: "\u25B2"
|
||||
--- !u!1 &533265677507930414
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5032456400239506456}
|
||||
- component: {fileID: 6984345048618575931}
|
||||
- component: {fileID: 6416618677973573117}
|
||||
m_Layer: 0
|
||||
m_Name: DayTimeLabel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &5032456400239506456
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 533265677507930414}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7060217674643716524}
|
||||
m_RootOrder: 10
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 140.4, y: -48}
|
||||
m_SizeDelta: {x: 80, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6984345048618575931
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 533265677507930414}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &6416618677973573117
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 533265677507930414}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 0
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 16
|
||||
m_FontStyle: 1
|
||||
m_BestFit: 0
|
||||
m_MinSize: 0
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 0
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 1
|
||||
m_VerticalOverflow: 1
|
||||
m_LineSpacing: 1
|
||||
m_Text: 12:00
|
||||
--- !u!1 &966857434456162494
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1677,6 +1756,7 @@ MonoBehaviour:
|
|||
pedStateText: {fileID: 7285285471400155620}
|
||||
pedVelocityText: {fileID: 6556768988591572453}
|
||||
radioStationText: {fileID: 261304231076654976}
|
||||
dayTimeText: {fileID: 6416618677973573117}
|
||||
m_radioStationLabelDuration: 3
|
||||
regularCrosshairTextureSizeMultiplier: 1
|
||||
rocketCrosshairTextureSizeMultiplier: 1.75
|
||||
|
@ -2355,6 +2435,7 @@ MonoBehaviour:
|
|||
m_spaceAfterContent: 0
|
||||
m_registerInMainMenuOnStart: 0
|
||||
m_sortPriorityForMainMenu: 0
|
||||
availableHours: 070c0f12150003
|
||||
--- !u!114 &2436513682835006603
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -7421,6 +7502,7 @@ RectTransform:
|
|||
- {fileID: 2222193836290576247}
|
||||
- {fileID: 122172316996072528}
|
||||
- {fileID: 8743615454504171472}
|
||||
- {fileID: 5032456400239506456}
|
||||
m_Father: {fileID: 5719983600610341389}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace SanAndreasUnity.Behaviours.World
|
|||
|
||||
public float CurrentCurveTime => (this.CurrentTimeHours + this.CurrentTimeMinutes / 60f) / 24f;
|
||||
|
||||
public string CurrentTimeAsString => FormatTime(this.CurrentTimeHours, this.CurrentTimeMinutes);
|
||||
|
||||
private float m_timeSinceTimeAdvanced = 0;
|
||||
|
||||
public float timeScale = 1;
|
||||
|
@ -157,5 +159,10 @@ namespace SanAndreasUnity.Behaviours.World
|
|||
float hourPerc = hoursWithMinutes - Mathf.Floor(hoursWithMinutes);
|
||||
minutes = (byte) Mathf.RoundToInt(60 * hourPerc);
|
||||
}
|
||||
|
||||
public static string FormatTime(byte hours, byte minutes)
|
||||
{
|
||||
return $"{hours:00}:{minutes:00}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using SanAndreasUnity.Utilities;
|
|||
using UnityEngine.UI;
|
||||
using SanAndreasUnity.Importing.Conversion;
|
||||
using SanAndreasUnity.Behaviours.Vehicles;
|
||||
using SanAndreasUnity.Behaviours.World;
|
||||
|
||||
namespace SanAndreasUnity.UI {
|
||||
|
||||
|
@ -20,6 +21,7 @@ namespace SanAndreasUnity.UI {
|
|||
public Text pedStateText;
|
||||
public Text pedVelocityText;
|
||||
public Text radioStationText;
|
||||
public Text dayTimeText;
|
||||
|
||||
[SerializeField] [Range(0.3f, 10f)] float m_radioStationLabelDuration = 3f;
|
||||
|
||||
|
@ -244,6 +246,7 @@ namespace SanAndreasUnity.UI {
|
|||
this.healthForegroundImage.enabled = false;
|
||||
this.pedStateText.enabled = false;
|
||||
this.pedVelocityText.enabled = false;
|
||||
this.dayTimeText.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -265,6 +268,14 @@ namespace SanAndreasUnity.UI {
|
|||
this.pedVelocityText.text = pedVelocityDisplayText;
|
||||
}
|
||||
|
||||
this.dayTimeText.enabled = DayTimeManager.Singleton != null;
|
||||
if (this.dayTimeText.enabled)
|
||||
{
|
||||
string dayTimeDisplayText = DayTimeManager.Singleton.CurrentTimeAsString;
|
||||
if (this.dayTimeText.text != dayTimeDisplayText)
|
||||
this.dayTimeText.text = dayTimeDisplayText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue