Convert pictures to sprite sprite in Ugui

Source: Internet
Author: User

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

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.