/// <summary>
/// 创建精灵
/// </summary>
/// <param name="url">路径</param>
/// <returns></returns>
public static Sprite CreateSprite (string url) {
Texture2D texture = AssetSystem.Load (url) as Texture2D;
if (texture == null) return null;
Sprite sp = Sprite.Create (
texture,
new Rect (0, 0, texture.width, texture.height),
new Vector2 (0.5f, 0.5f));
return sp;
}
使用方式:
sp.sprite = 类名.CreateSprite ("图片路径");