2016年10月14日 星期五

時間




using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;

public class NewBehaviourScript2 : MonoBehaviour {
public bool timerOn =  true;
float time;
// Use this for initialization
void Start () {


}

// Update is called once per frame
void Update () {


if (timerOn) {
time += Time.deltaTime;
}

Text mytxt = GameObject.Find ("Canvas/Panel/Text").GetComponent<Text> ();
//mytxt.text =Random.Range(1,4).ToString();
mytxt.text = System.DateTime.Now.ToString ();


}


}

剪刀石頭布



using UnityEngine; using System.Collections; using UnityEngine.UI; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } public void myfun() { int num = Random.Range (1, 4); Text mytxt = GameObject.Find ("Canvas/Panel/Text").GetComponent<Text> (); mytxt.text =num.ToString(); Image Imgy = GameObject.Find ("Canvas/Panel/Image").GetComponent<Image>(); Imgy.sprite=Resources.Load<Sprite>("Image/"+num) as Sprite; } }