38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
using System;
|
||
|
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;
|
||
|
[SerializeField] private CozyController cozyController;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
StartCoroutine(nameof(TimeCoroutine));
|
||
|
}
|
||
|
|
||
|
private IEnumerator TimeCoroutine()
|
||
|
{
|
||
|
while (true)
|
||
|
{
|
||
|
Date.text = CozyWeather.instance.timeModule.currentDay + " Days";
|
||
|
Time.text = CozyWeather.instance.timeModule.currentTime.ToString();
|
||
|
WeatherIcon.sprite = cozyController.CurrentWeatherInfo.Sprite;
|
||
|
|
||
|
yield return new WaitForSeconds(updateTime);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|