using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{
public bool timerOn = false;
float time;
// Use this for initialization
void Start()
{
time = 3;
timerOn = false;
}
// Update is called once per frame
void Update()
{
Text mytxt3 = GameObject.Find("Canvas/Panel/Text3").GetComponent<Text>();
if (timerOn == true&& time>0)
{
time = time- Time.deltaTime;
mytxt3.text = time.ToString();
}
if(timerOn == true && time < 0)
{
time = 0;
mytxt3.text = time.ToString();
}
Text mytxt1 = GameObject.Find("Canvas/Panel/Text").GetComponent<Text>();
mytxt1.text = System.DateTime.Now.ToString("MM/dd/yyyy");
Text mytxt = GameObject.Find("Canvas/Panel/Text2").GetComponent<Text>();
mytxt.text = System.DateTime.Now.ToString("hh:mm:ss");
}
public void startB()
{
timerOn = true;
}
public void stopB()
{
if (time == 0)
{
Text mytxt3 = GameObject.Find("Canvas/Panel/Text3").GetComponent<Text>();
time = 3;
mytxt3.text = time.ToString();
}
timerOn = false;
}
}
沒有留言:
張貼留言