現在時刻の表示



現在時刻の表示
using System;
using TMPro;
using UnityEngine;
public class CurrentTime : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
void Update()
{
DateTime now = DateTime.Now;
timeLabel.text = now.ToString("yyyy/MM/dd HH/mm/ss");
}
}


一定時間ごとに文字を赤くする
using System;
using TMPro;
using UnityEngine;
public class CurrentTime : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
void Update()
{
DateTime now = DateTime.Now;
// ★追加
int second = now.Second;
if (second % 4 == 0)
{
timeLabel.color = Color.red;
}
else
{
timeLabel.color = Color.white;
}
timeLabel.text = now.ToString("yyyy/MM/dd HH/mm/ss");
}
}
【Unity6版】VR_Dungeon(全18回)
他のコースを見る


現在時刻の表示
using System;
using TMPro;
using UnityEngine;
public class CurrentTime : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
void Update()
{
DateTime now = DateTime.Now;
timeLabel.text = now.ToString("yyyy/MM/dd HH/mm/ss");
}
}


一定時間ごとに文字を赤くする
using System;
using TMPro;
using UnityEngine;
public class CurrentTime : MonoBehaviour
{
public TextMeshProUGUI timeLabel;
void Update()
{
DateTime now = DateTime.Now;
// ★追加
int second = now.Second;
if (second % 4 == 0)
{
timeLabel.color = Color.red;
}
else
{
timeLabel.color = Color.white;
}
timeLabel.text = now.ToString("yyyy/MM/dd HH/mm/ss");
}
}
現在時刻の表示