上一篇中讲述了NGUI动态打图集的功能,提到UGUI将图片转换长Sprite格式,其实网上也有好多,那我在这简单的说一下,

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class CreateTexture : MonoBehaviour {


    private Image p_w_picpath;

    void Awake()
    {
        p_w_picpath = GameObject.FindWithTag("Image").GetComponent<Image>();
    }

	// Use this for initialization
	void Start () {
        CreateSprite();
	
	}
	//将Resources中得到图片Pic_01转成精灵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));//后面Vector2就是你Anchors的Pivot的x/y属性值
        p_w_picpath.sprite = pic;
 
    }

}

大家可以简单了看一下。。。也许会有帮助