Textures from a Texture Atlas

Hi,

I am new to Unity and could really use some help with some suggestions of methods to accomplish a few things. I am working on an Eye of the Beholder style game. I was hoping to find a way to load textures from a texture atlas. I currently have everything working using Graphics.DrawTexture and GUI.DrawTextureWithCoords (for flipping textgures. This works okay but I could save so many draw calls and swap out my tile sets without loading each tile uniquely. Right now I am loading 27 individual textures. I know all the coords in the Texture Atlas I created so I would like a way to load a texture and then grab sections of the texture to draw at specific coords on the screen.

I thought about using sprites and sprite sheet but using sprite.renderer I couldn’t for the life of me figure out how to move sprites around in C#.

Any suggestions?

Hi @Cancerboy

The GetPixels API for Texture2D should get you what you need:

1 Like

Thanks @rustum ! That worked. It took a little bit to figure out that it was reading the texture from bottom to top but once I got that sorted (and setting the filter to point to handle my scaling blurring) I was good to go. This will save me a lot of headaches! Thanks!