Skip to content

Instantly share code, notes, and snippets.

@paraself
Created May 6, 2014 05:53
Show Gist options
  • Save paraself/a5f30af105c1d391e441 to your computer and use it in GitHub Desktop.
Save paraself/a5f30af105c1d391e441 to your computer and use it in GitHub Desktop.
Unity Runtime Atlas Creation
Texture texture = new Texture2D(maximunAtlasSize, maximunAtlasSize);
texture.PackTextures(frames, padding, maximunAtlasSize);
texture.name = "New Atlas";
texture.Apply();
if(!Directory.Exists(Application.dataPath + "/Atlases"))
Directory.CreateDirectory(Application.dataPath + "/Atlases");
FileStream fs = new FileStream(Application.dataPath + "/Atlases/" + texture.name + ".png", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(texture.EncodeToPNG());
bw.Close();
fs.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment