mirror of
https://github.com/DerTyp7/example-top-down-unity.git
synced 2026-07-31 07:19:03 +02:00
added TimeUI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class Calendar : MonoBehaviour
|
||||
{
|
||||
@@ -11,6 +12,13 @@ public class Calendar : MonoBehaviour
|
||||
[SerializeField]
|
||||
Color currentDayColor;
|
||||
Color originDayColor;
|
||||
|
||||
[SerializeField]
|
||||
TextMeshProUGUI monthText;
|
||||
[SerializeField]
|
||||
TextMeshProUGUI yearText;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
daysTransform = transform.Find("Days");
|
||||
@@ -32,6 +40,9 @@ public class Calendar : MonoBehaviour
|
||||
|
||||
int daysInMonth = DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
|
||||
|
||||
monthText.text = dateTime.ToString("MMMM");
|
||||
yearText.text = dateTime.ToString("yyyy");
|
||||
|
||||
counter = 1;
|
||||
while (counter <= 31)
|
||||
{
|
||||
|
||||
23
Assets/Scripts/TimeUI.cs
Normal file
23
Assets/Scripts/TimeUI.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class TimeUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
TextMeshProUGUI dateTimeText;
|
||||
TimeManager timeManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeManager = GameObject.Find("GameManager").GetComponent<TimeManager>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
DateTime dateTime = timeManager.GetDateTime();
|
||||
if (dateTimeText != null)
|
||||
dateTimeText.text = dateTime.ToString("hh:mm tt / dd.MM.yyyy");
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TimeUI.cs.meta
Normal file
11
Assets/Scripts/TimeUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e980066e5baa94e4c993240ec95348fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user