Skip to content

Instantly share code, notes, and snippets.

@robotron2084
Created March 1, 2016 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotron2084/2c26d89d8154cb7bc9ce to your computer and use it in GitHub Desktop.
Save robotron2084/2c26d89d8154cb7bc9ce to your computer and use it in GitHub Desktop.
Texture Import Settings
using UnityEngine;
using UnityEditor;
public static class ProjectMenuUtil
{
[MenuItem ("Assets/Import For PixelWave")]
public static void ImportForWave()
{
foreach(Object o in Selection.objects)
{
if(o is Texture2D)
{
string path = AssetDatabase.GetAssetPath(o);
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
importer.filterMode = FilterMode.Point;
importer.isReadable = true;
importer.textureType = TextureImporterType.Advanced;
importer.mipmapEnabled = false;
importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
importer.spriteImportMode = SpriteImportMode.None;
importer.SaveAndReimport();
}
}
}
[MenuItem ("Assets/Import For UI")]
public static void ImportForUI()
{
foreach(Object o in Selection.objects)
{
if(o is Texture2D)
{
string path = AssetDatabase.GetAssetPath(o);
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
importer.filterMode = FilterMode.Point;
importer.textureType = TextureImporterType.Advanced;
importer.mipmapEnabled = false;
importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
importer.SaveAndReimport();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment