|  | 
 
| 创建一个TEXT  UI 
 
   
 
 将下面这段此代码拖放在相机上。
 
 
 复制代码using UnityEngine;
using System;
using System.Collectio自行去掉汉字ns;
using UnityEngine.UI;
public class Testdata : MonoBehaviour
{
    private Text CurrentGX;
    private int hour;
    private int minute;
    private int second;
    private int year;
    private int month;
    private int day;
    void Start()
    {
        //CurrentGX = GetComponent<Text>();
        CurrentGX = GameObject.Find("Canvas/Text").GetComponent<Text>();
        //text.text = "WWW.GALAXIX.COM";
    }
    void Update()
    {
        hour = DateTime.Now.Hour;
        minute = DateTime.Now.Minute;
        second = DateTime.Now.Second;
        year = DateTime.Now.Year;
        month = DateTime.Now.Month;
        day = DateTime.Now.Day;
        CurrentGX.text = string.Format("{0:D2}:{1:D2}:{2:D2} " + "{3:D2}:{4:D2}:{5:D2}", hour, minute, second, year, month, day);
    #if UNITY_EDITOR
        Debug.Log("W now " + System.DateTime.Now);      //当前时间(年月日时分秒)
        Debug.Log("W utc " + System.DateTime.UtcNow);   //当前时间(年月日时分秒)
    #endif
        /*
        Debug.Log("W now  " + System.DateTime.Now);        //当前时间(年月日时分秒)  
        Debug.Log("W utc  " + System.DateTime.UtcNow);     // 当前时间(年月日时分秒)  
        Debug.Log("W year  " + System.DateTime.Now.Year);  //当前时间(年)  
        Debug.Log("W month   " + System.DateTime.Now.Month); //当前时间(月)  
        Debug.Log("W day   " + System.DateTime.Now.Day);    // 当前时间(日)  
        Debug.Log("W h    " + System.DateTime.Now.Hour);  // 当前时间(时)  
        Debug.Log("W min   " + System.DateTime.Now.Minute);  // 当前时间(分)  
        Debug.Log("W second   " + System.DateTime.Now.Second); // 当前时间(秒)  
        */
    }
}
 播放测试,就可以看到这里有动态的当前时间在刷新了。
 
 
   
 | 
 |