Unity3d Get System Time

  • 2021-08-17 00:41:51
  • OfStack

Unity is a multi-platform comprehensive game development tool developed by Unity Technologies, which allows players to easily create interactive content such as 3D video games, architectural visualization, real-time 3D animation, etc. It is a fully integrated professional game engine. Unity is similar to software such as Director, Blender game engine, Virtools or Torque Game Builder, which uses interactive graphical development environment as the primary mode. Its editor runs under Windows and Mac OS X, and can publish games to Windows, Mac, Wii, iPhone, Windows phone 8 and Android platforms. You can also use Unity web player plug-in to publish web games and support Mac and Windows web browsing. Its web player is also supported by Mac widgets.

The following is a code to introduce unity3d to get system time.

The specific code is as follows:


var gSkin:GUISkin;
var str="";
var  Months:String[]=["1 Month ","2 Month ","3 Month ","4 Month ","5 Month ","6 Month ","7 Month ","8 Month ","9 Month ","10 Month ","101 Month ","102 Month "];
var  Days:String[]= [" 1 "," 2 "," 3 "," 4 "," 5 "," 6 "," 7 "," 8 "," 9 ","10","11","12","13","14","15","16","17","18","19","20",
"21","22","23","24","25","26","27","28","29","30","31"];
var  dNow:System.DateTime;
var i=0;
function OnGUI()
{if(gSkin)GUI.skin=gSkin;
  GUILayout.Box(" Local date and time: "+System.DateTime.Now);// Local time, 12 Hourly 
  GUILayout.Box(" Military date and time: "+System.DateTime.Now.ToString("yyyyMMddHHmmss"));
  GUILayout.Box("UTC Date and time: "+System.DateTime.UtcNow);//UTC Time 
GUILayout.SelectionGrid(System.DateTime.Now.Month-1,Months,3);
  GUILayout.SelectionGrid(System.DateTime.Now.Day-1,Days,10);
  GUILayout.Box(str+dNow.Now.Year+" Year "+dNow.Now.Month+" Month "+dNow.Now.Day+"  Day "+"  "+dNow.Now.Hour+" Hour "+dNow.Now.Minute+" Points "+dNow.Now.Second+" Seconds ");
}

The above code is about Unity3d to obtain the system time of the whole content, the code is accompanied by comments, where the writing is not good places welcome you warriors to put forward valuable opinions. Thank you


Related articles: