Created
May 6, 2014 05:53
-
-
Save paraself/a5f30af105c1d391e441 to your computer and use it in GitHub Desktop.
Unity Runtime Atlas Creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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