In the previous article described the Ngui dynamic map set function, mentioned Ugui to convert the image of the long sprite format, in fact, there are many online, then I say in this simple,
using unityengine;using system.collections;using unityengine.ui;public class createtexture : monobehaviour { private image image; void awake () { Image = gameobject.findwithtag ("Image"). Getcomponent<image> (); }// use this for initializationvoid Start () { createsprite ();} Take the resources and get the picture pic_01 turn into Elf sprite public void createsprite () { texture2d img = resources.load (" Pic_01 ") as Texture2D; Sprite pic = Sprite.create (Img, new rect (0, 0, img.width, img.height), new Vector2 (0.5f, 0.5f);//The back Vector2 is your anchors pivot's X/Y property value image.sprite = &NBSP;PIC;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP:} You can simply take a look ... It might help.
This article is from the "Unity_3d Technology discussion" blog, please be sure to keep this source http://caoliyong.blog.51cto.com/9944020/1735020
Convert pictures to sprite sprite in Ugui