OldBlueWater/BlueWater/Assets/02.Scripts/Ui/WeatherUi.cs

41 lines
1.2 KiB
C#
Raw Normal View History

using System.Collections;
using DistantLands.Cozy;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
// ReSharper disable once CheckNamespace
namespace BlueWaterProject
{
public class WeatherUi : MonoBehaviour
{
[field: SerializeField] public TMP_Text Date { get; set; }
[field: SerializeField] public TMP_Text Time { get; set; }
[field: SerializeField] public Image WeatherIcon { get; set; }
[SerializeField] private float updateTime = 1f;
private void Start()
{
StartCoroutine(nameof(TimeCoroutine));
}
private IEnumerator TimeCoroutine()
{
2024-04-02 05:09:52 +00:00
while (!CozyWeather.instance || !CozyManager.Inst)
2024-04-02 02:43:43 +00:00
{
yield return new WaitForSeconds(updateTime);
}
while (true)
{
Date.text = CozyWeather.instance.timeModule.currentDay + " Days";
Time.text = CozyWeather.instance.timeModule.currentTime.ToString();
2024-04-02 02:10:51 +00:00
WeatherIcon.sprite = CozyManager.Inst.CurrentWeatherInfo.Sprite;
yield return new WaitForSeconds(updateTime);
}
}
}
}