using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; /// /// 为文本框显示当前时间 /// public class ShowNowTime : MonoBehaviour { public Text[] Text_Time; public InputField [] In_Time; int i; string Str_Time; void Start() { //设置当前时间 Str_Time = DateTime.Now.Year.ToString(); if (DateTime.Now.Month < 10) Str_Time += "-0" + DateTime.Now.Month; else Str_Time += "-" + DateTime.Now.Month; if (DateTime.Now.Day < 10) Str_Time += "-0" + DateTime.Now.Day; else Str_Time += "-" + DateTime.Now.Day; for (i = 0; i < Text_Time.Length; i++) Text_Time[i].text = Str_Time; for (i = 0; i < In_Time.Length; i++) In_Time[i].text = Str_Time; } }