Forum Discussion
RCopelan
Apr 12, 2024Copper Contributor
Accessing Current Date/Time in Visual Scripting
I am attempting to build a "Current Time Clock" to include in our Mesh custom meeting room. Easy to do with a TMP-Text object and attached C# script in Unity but that won't work when building for Mesh. Since we don't (currently) have a requirement in this environment for any Cloud Scripting functionality other than getting Current date/time I would rather NOT have to add those resources just to get datetime.now().
Does anyone have thoughts on doing this with only Visual Scripting (or some other way that works in Mesh) as we can easily update the text object in Visual Script... just need the time data.
Thanks for any ideas.
- RCopelanCopper ContributorPosting 2 solutions to this ... the 2nd one is what I targeted in the begining but just over the weekend found the appropriate nodes. The 1st one was suggested by a colleague and worked well. 1. Using a Webslate in the scene sized and styled to be a clock I displaed a webpage that was hosted on github pages that used JavaScript and CSS to show a clock. The JavaScript ran the clock. Worked very well but does require the page to be hosted somewhere. 2. Visual Script has nodes "Date Time Get Now" and "Date Time To String" . The output of To String can feed a TextMeshPro object. Triggered by an "On Interval" node it is within a fraction of a second of my PC clock. Close enough for my Events. There are other "Date Time" nodes in the picker. I appreciate the external collaboration on this.
- kaipiroskaBrass Contributor
Hi, I have implemented an analog clock with Visual Scripting which takes the current time on event start and then updates hour and minute hands every 60 seconds.
- RCopelanCopper ContributorThat's really neat. Tnx for sharing