using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour {
void Start (){
}
void Update () {
}
public void click(){
int randNum = Random.Range(1, 4);
Text inform = GameObject.Find("Canvas/Panel/Text").GetComponent<Text>();
inform.text = randNum.ToString();
Image img = GameObject.Find("Canvas/Panel/Image").GetComponent<Image>();
img.sprite = Resources.Load<Sprite>("image/" + randNum) as Sprite;
}
}
沒有留言:
張貼留言