2016年10月7日 星期五



========================================================================
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; } }

沒有留言:

張貼留言