- Home /
How can I manage that a 3dtext show date?
Hello everyone,
My problem is I have a 3dText game object in the scene and I want to make that 3dtext object shows the current date. How can I print current date as 3dtext?
Thanks.
Answer by Vega4Life · Dec 15, 2018 at 05:11 PM
Here is a simple script - just place it on your text object and link the textMesh as the reference.
using UnityEngine;
public class DisplayTime : MonoBehaviour
{
[SerializeField] TextMesh timeText;
void Update()
{
System.DateTime current = System.DateTime.Now;
timeText.text = string.Format("{0}/{1}/{2}", current.Day, current.Month, current.Year);
}
}
As a tip, I wouldn't use textmesh anymore. Everyone should be using TextMeshPro. If you are using it, then just switch out the text type.
Good luck!
Thanks Vega4life, it works but it shows only time in "08:38 P$$anonymous$$" format. I need date, like DD/$$anonymous$$$$anonymous$$/YYYY format not including time.
Thank you very much. It works perfectly.
Your answer
Follow this Question
Related Questions
TextMesh update causing framerate drop 1 Answer
Input 3D text with script? 1 Answer
How to save 3d text 1 Answer
Updating LCD display? 1 Answer
How do you create genuine shadows from a Text Mesh? 1 Answer