Unity Tip: Importing Textures

Usually when working with textures in Unity you may have a few specific requirements on how textures should be imported. Compression, mip-maps, filter mode, and wrap are usually my most commonly set flags. I’ve taken to writing a small chunk of editor code to help me set the properties of my images without requiring manually flipping the bits. This means I can select then right-click on all my images and set the texture settings to exactly what I want with one click:


The full script is below. I iterate over the currently selected objects in the editor and if it is a Texture2D ( Sprites exist within Texture2Ds so you can select them as well). I then create a TextureImporter object for the texture, which lets you set the ‘bake’ settings. You can see that I have some non-standard things I’m doing, partially due to this project being an 8-bit style. I want the filter mode set to ‘Point’. And since the images are tiny I do not think texture compression is worthwhile so I set it to true color. Among a few other details.