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