private static void AddSticker(StickerPack pack) { var name = pack.Title; var path = ExportPath + name; ExportIcons(pack, path); ExportStickers(pack, path); }
public static JsonDocument CreateStickerListContent(StickerPack pack) { var content = CreateContent(); var stickerList = content.root.CreateArray("stickers"); foreach (var sticker in pack.Stickers) { stickerList.AddDict().SetString("filename", sticker.name + ".sticker"); } // Add info var info = content.root.CreateDict("info"); info.SetInteger("version", 1); info.SetString("author", "xcode"); // Add properties var properties = content.root.CreateDict("properties"); properties.SetString("grid-size", Enum.GetName(typeof(StickerSize), pack.Size).ToLowerInvariant()); return(content); }
private static void ExportIcons(StickerPack pack, string path) { var pathToAppIcons = path + "/Stickers.xcassets/iMessage App Icon.stickersiconset"; if (!Directory.Exists(pathToAppIcons)) { Log("Creating " + pathToAppIcons); Directory.CreateDirectory(pathToAppIcons); } var iconContent = CreateIconContent(pack.Icons); iconContent.WriteToFile(pathToAppIcons + "/Contents.json"); var icons = pack.Icons.Textures; foreach (var icon in icons) { var fileName = pathToAppIcons + "/" + icon.name + ".png"; Log("Copying " + icon.name + " to " + fileName); File.WriteAllBytes(fileName, icon.EncodeToPNG()); } }
private static void ExportStickers(StickerPack pack, string path) { var pathToProject = Application.dataPath.Replace("/Assets", string.Empty); var pathToStickers = path + "/Stickers.xcassets/Sticker Pack.stickerpack"; if (!Directory.Exists(pathToStickers)) { Log("Creating " + pathToStickers); Directory.CreateDirectory(pathToStickers); } var pathToContent = path + "/Stickers.xcassets/Contents.json"; var contents = CreateStickerPackContent(pack.Size); contents.WriteToFile(pathToContent); var pathToStickersListContent = pathToStickers + "/Contents.json"; var stickerListContent = CreateStickerListContent(pack); Log("Writing sticker list content to " + pathToStickersListContent); stickerListContent.WriteToFile(pathToStickersListContent); var plist = CreatePList(pack.Title, PlayerSettings.bundleVersion, PlayerSettings.iOS.buildNumber); plist.WriteToFile(path + "/Info.plist"); foreach (var sticker in pack.Stickers) { if (sticker.Frames.Count == 1) { ExportSticker(pathToStickers, sticker, pathToProject); } else { ExportStickerSequence(pathToStickers, sticker, pathToProject); } } }