} // Extension of the Original Image. #endregion /// <summary> /// Extract the Sub Sprites of a Sprite Sheet using the Metadata generated by using the Unity Sprite Editor. /// </summary> public void ExtractSprites() { // Get The meta Data of the Sub Sprite Artwork. _subSprites = AssetDatabase.LoadAllAssetRepresentationsAtPath(SpriteSheetPath); for (int i = 0; i < _subSprites.Length; i++) { _subTexture = ((Sprite)_subSprites[i]).texture; _subTextureRect = ((Sprite)_subSprites[i]).textureRect; _extractedTexture = _subTexture.CropTexture2D((int)_subTextureRect.x, (int)_subTextureRect.y, (int)_subTextureRect.width, (int)_subTextureRect.height); data = _extractedTexture.EncodeToPNG(); File.WriteAllBytes(SavePath.Combine("/", ((Sprite)_subSprites[i]).name, ".png"), data); } AssetDatabase.Refresh(); }