自動對導入的Texture進行基礎(chǔ)設(shè)置
using UnityEngine;
using UnityEditor;
using System.IO;
public class AutoAssetsImportSitting : AssetPostprocessor {
/// <summary>
/// Hook驹愚,用于自動設(shè)置導入Texture的設(shè)置
/// 1.把導入的圖片默認設(shè)置為Sprite
/// 2.設(shè)置spriteMode默認為Single
/// 3.設(shè)置Packing Tag為存放Texture的文件夾名
/// 4.取消Mipmap的勾選
/// 5.設(shè)置為帶透明通道
/// 6.設(shè)置Read/Write Enable狀態(tài)為未勾選
/// 7.設(shè)置wrapMode默認為Clamp
/// </summary>
/// <param name="texture"></param>
void OnPostprocessTexture(Texture2D texture){
string AtlasName = new DirectoryInfo(Path.GetDirectoryName(assetPath)).Name;
TextureImporter textureImporter = assetImporter as TextureImporter;
textureImporter.textureType = TextureImporterType.Sprite;
textureImporter.spriteImportMode = SpriteImportMode.Single;
textureImporter.spritePackingTag = AtlasName;
textureImporter.mipmapEnabled = false;
textureImporter.alphaIsTransparency = true;
textureImporter.isReadable = false;
textureImporter.wrapMode = TextureWrapMode.Clamp;
}
}