查看: 3996|回复: 0
打印 上一主题 下一主题

[其他] Unity3d获取当前系统时间的代码

[复制链接]

711

主题

10

听众

5805

积分

高级设计师

Rank: 6Rank: 6

纳金币
2954
精华
3

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2014-5-26 02:22:57 |显示全部楼层 |倒序浏览
unity3d中获取系统时间的代码:
  1. var gSkin:GUISkin;

  2. var str="";
  3. var        Months:String[]=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];
  4. var        Days:String[]= ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20",
  5. "21","22","23","24","25","26","27","28","29","30","31"];
  6. var        dNow:System.DateTime;
  7. var i=0;

  8. function OnGUI()
  9. {if(gSkin)GUI.skin=gSkin;
  10.         GUILayout.Box("本地日期时间:"+System.DateTime.Now);//本地时间,12小时制的
  11.         GUILayout.Box("军事日期时间:"+System.DateTime.Now.ToString("yyyyMMddHHmmss"));
  12.         GUILayout.Box("UTC日期时间:"+System.DateTime.UtcNow);//UTC时间
  13.       
  14. GUILayout.SelectionGrid(System.DateTime.Now.Month-1,Months,3);
  15.         GUILayout.SelectionGrid(System.DateTime.Now.Day-1,Days,10);
  16.       
  17.         GUILayout.Box(str+dNow.Now.Year+"年"+dNow.Now.Month+"月"+dNow.Now.Day+" 日"+"        "+dNow.Now.Hour+"时"+dNow.Now.Minute+"分"+dNow.Now.Second+"秒");
  18.       
  19. }
复制代码
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-1 06:50 , Processed in 0.141227 second(s), 29 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部