unity3d-Game Combat Siege, the third day to draw the numbers

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.