/// <summary> /// Save to disk the DynamicAtlas. /// </summary> /// <param name="atlas">DynamicAtlas.</param> /// <param name="info">Custom FileInfo.</param> /// <returns>Return FileInfo (Path and Name of saved atlas).</returns> public static FileInfo Save(DynamicAtlas atlas, FileInfo info = null) { if (info == null) { info = new FileInfo(atlas.Texture.name); } if (Directory.Exists(info.Path) == false) { Directory.CreateDirectory(info.Path); } if (atlas.IsApplied == false) { atlas.Apply(); } byte[] bytes = atlas.Texture.EncodeToPNG(); string json = JsonUtility.ToJson(atlas); File.WriteAllBytes(info.PathTexture, bytes); File.WriteAllText(info.PathData, json); return(info); }
public void Apply() { if (AtlasIsNull()) { return; } atlas.Apply(); }