123456789101112131415161718192021222324 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using UnityEngine;
- public static class SpriteExtension
- {
- public static Texture2D ToTexture(this Sprite sprite)
- {
- int width = (int)sprite.rect.width;
- int height = (int)sprite.rect.height;
- int startX = (int)sprite.rect.x;
- int startY = (int)sprite.rect.y;
- //Debug.Log(width);
- //Debug.Log(height);
- //Debug.Log(startX);
- //Debug.Log(startY);
- Texture2D texture = new Texture2D(width, height);
- texture.SetPixels(sprite.texture.GetPixels(startX, startY, width, height));
- texture.Apply();
- return texture;
- }
- }
|