unity 距离某天还有多久

来源:互联网 发布:掌淘科技 游族网络 编辑:程序博客网 时间:2024/05/16 01:49

距离某一天还有多久,简单的小例子.

using UnityEngine;using System.Collections;using System;public class test : MonoBehaviour {    DateTime dt1;    DateTime dt2;    TimeSpan ts;    public GameObject mObj;    private UILabel mLab;// Use this for initializationvoid Start () {         dt2 = new DateTime(2014,1,18);     mLab = mObj.GetComponent<UILabel>();}// Update is called once per framevoid Update () {dt1 = DateTime.Now;ts = dt1.Subtract(dt2);        mLab.text = ts.ToString();    Debug.Log(ts);}}


原创粉丝点击