using UnityEngine;
using System.Collections;
public class DjScrene2 : MonoBehaviour
{
//获取图片资源的容器
Object[] texPic;
//要显示的数字
int num = 2013;
void Start()
{
//获取图片资源
texPic = Resources.LoadAll("Textures");
}
void OnGUI()
{
//绘制数字
DrawImageNumber(0,100,num,texPic);
}
//x为绘制数字的x轴坐标,y为y轴坐标,texes 图片资源的数组
void DrawImageNumber(int x, int y ,int number,Object[] texes)
{
//将整形转成字符数组
char[] chars = num.ToString().ToCharArray();
//获取一张图片
Texture2D tex = (Texture2D)texPic[0];
//得到宽度
int width = tex.width;
//得到高度
int height = tex.height;
//遍历字符数组
foreach(char s in chars)
{
//得到每一位整形数据
int i = int.Parse(s.ToString());
//绘制数字
GUI.DrawTexture(new Rect(x,0,width,height),(Texture2D)texes[i]);
x += width;
}
}
}