您好,登錄后才能下訂單哦!
上一篇中講述了NGUI動態(tài)打圖集的功能,提到UGUI將圖片轉換長Sprite格式,其實網(wǎng)上也有好多,那我在這簡單的說一下,
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; } } 大家可以簡單了看一下。。。也許會有幫助
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。