Unity3d-Drawing Maps

Source: Internet
Author: User

Prepare stickers

To draw a static map on the screen, you need to use the Gui.drawtexture () method, which can set the display position of the picture, scale and rendering mix, etc.

/ *                Rect Position: Represents the drawing area of a picture             * Texture Image: The object that represents the drawing picture             * ScaleMode ScaleMode: The zoom mode for the picture             * BOOL AlphaBlend: Indicates that the picture blending mode is very open             * Float imageaspect: Indicates a picture of             a scaled-up high proportion               */Public staticvoidboolfloat imageaspect);

In Project view, you will need to save the parent's picture in the root directory "resources", remember to keep in the resources, this is unity3d stipulated, otherwise cannot load!! Load and draw map load maps using the Resources.load () and Resources.loadall () methods,
1 usingUnityengine;2 usingSystem.Collections;3 4  Public classLoadtext2d:monobehaviour5 {6 7     Privatetexture2d txt;8 texture2d[] array;9     //Use this for initializationTen     voidStart () One     { A  -     } -  the     //Update is called once per frame -     voidUpdate () -     { -  +     } -     voidOngui () +     { A         //Load Map at         if(GUI. Button (NewRect (Ten, -, -, -),"Load a picture")) -         { -txt = resources.load<texture2d> ("one/0"); -         } -         if(GUI. Button (NewRect (Ten, Max, -, -),"load All pictures")) -         { inArray = resources.loadall<texture2d> (" More"); -         } to         //Draw a map +         if(TXT! =NULL) -         { theGui. Drawtexture (NewRect ( Max, -, -, -), TXT, Scalemode.stretchtofill,true,0); *         } $         if(Array! =NULL)Panax Notoginseng         { -              for(inti =0; I < array. Length; i++) the             { +Gui. Drawtexture (NewRect ( Max+ I * the, Max, -, -), Array[i], Scalemode.scaletofit,true,0); A             } the              +  -         } $     } $}

Demo Demos

Unity3d-Drawing Maps

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.