Implementation results:
Preparing resources
1 usingUnityengine;2 usingSystem.Collections;3 4 Public classHznum:monobehaviour {5 6 //storing an array of picture resources7 object[] Texmube;8 //Test Integer Data9 intNumber =1980;Ten voidStart () One { A //reading a picture resource -Texmube = Resources.loadall ("Textures"); - } the voidOngui () { - //draw a picture number -Drawimagenumber (0, -, number, texmube); - } + /// <summary> - ///draw a picture number + /// </summary> A /// <param name= "x" >draw the number x coordinate</param> at /// <param name= "y" >Draw the y-coordinate of a number</param> - /// <param name= "number" >the number currently needed to be drawn</param> - /// <param name= "Texmube" >drawing a picture array resource</param> - voidDrawimagenumber (intXintYintNumber , object[] texmube) - { - //converting integer data to character arrays in Char[] chars =Number . ToString (). ToCharArray (); - to //Calculate the width and height of a picture +Texture2d Tex = (texture2d) texmube[0]; - intwidth =Tex.width; the intHeight =Tex.height; * $ //traversing character ArraysPanax Notoginseng foreach(CharCinchchars) - { the //get the first bit of the array of Zheng type data + inti =int. Parse (C.tostring ()); A //draw a picture number theGui. Drawtexture (NewRect (x,0, width, height), (texture2d) texmube[i]); +X + =width; - } $ } $ -}
Resources Download:
Http://pan.baidu.com/s/14gouM
unity3d-Game Combat Siege, the third day to draw the numbers