private static void Main(string[] args) { var files = Directory.GetFiles("Textures") .Select(f => new Texture { name = Path.GetFileNameWithoutExtension(f), path = f }).ToArray(); AtlasPlus atlas = new AtlasPlus(); Options options = new Options(); options.crop = true; options.algorithm = Algorithm.MaxRects; options.maxWidth = 512; options.maxHeight = 512; options.colorDepth = ColorDepth.TrueColor; options.format = Format.PNG; options.outputPath = "pack_m.png"; Options options2 = options; options2.outputPath = "pack_t.png"; options2.algorithm = Algorithm.TightRects; Options options3 = options; options3.outputPath = "pack_p.png"; options3.algorithm = Algorithm.Plain; Console.ReadLine(); Pack(files, atlas, options); Pack(files, atlas, options2); Pack(files, atlas, options3); Console.ReadLine(); }
private void OnWizardOtherButton() { string path = EditorUtility.SaveFilePanelInProject("Create Atlas", "atlas", "asset", "Save atlas asset"); if (!string.IsNullOrEmpty(path)) { atlas = CreateInstance <AtlasPlus>(); AssetDatabase.CreateAsset(atlas, path); } }
private static void CreateAtlas() { AtlasPlus atlas = CreateInstance <AtlasPlus>(); string path = EditorUtility.SaveFilePanelInProject("Create Atlas", "atlas", "asset", "Save atlas asset"); if (!string.IsNullOrEmpty(path)) { AssetDatabase.CreateAsset(atlas, path); } }
public static void Pack(Texture[] textures, AtlasPlus atlas, Options options, int debug = 0) { string json; if (Pack(textures, textures.Length, options, out json, debug)) { Console.WriteLine(json); File.WriteAllText(Path.ChangeExtension(options.outputPath, ".json"), json); } }
private void Start() { Texture2D[] textures = Resources.LoadAll <Texture2D>(""); AtlasPlus atlas = SharpPacker.Create(textures, width, height, false); image.texture = atlas.textures[0].texture; image.SetNativeSize(); for (int i = 0; i < images.Length && i < atlas.Count; i++) { images[i].Atlas = atlas; images[i].SpriteName = atlas.sprites[i].name; images[i].SetNativeSize(); } image.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, image.texture.height); }