Sprite 轉 Texture2D 程式:
////// sprite to Textrue2D /// /// ///Texture2D textureFromSprite(Sprite sprite) { if (sprite.rect.width != sprite.texture.width) { Texture2D image = new Texture2D(((int)sprite.rect.width), (int)sprite.rect.height); Color[] imageColors = sprite.texture.GetPixels((int)sprite.textureRect.x, (int)sprite.textureRect.y, (int)sprite.textureRect.width, (int)sprite.textureRect.height); image.SetPixels(imageColors); image.Apply(); return image; } else return sprite.texture; }
沒有留言:
張貼留言