UnityEditor脚本记录

自动对导入的Texture进行基础设置

using UnityEngine;
using UnityEditor;
using System.IO;
public class AutoAssetsImportSitting : AssetPostprocessor {

    /// <summary>
    /// Hook,用于自动设置导入Texture的设置
    /// 1.把导入的图片默认设置为Sprite
    /// 2.设置spriteMode默认为Single
    /// 3.设置Packing Tag为存放Texture的文件夹名
    /// 4.取消Mipmap的勾选
    /// 5.设置为带透明通道
    /// 6.设置Read/Write Enable状态为未勾选
    /// 7.设置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;
    }

}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,969评论 19 139
  • 1 纹理基础 纹理是一种结构化的存储形式(Textures are a structured form of st...
    RichardJieChen阅读 16,125评论 0 10
  • Unity3D 里有两种动态加载机制:一个是Resources.Load,另外一个通过AssetBundle,其实...
    IongX阅读 1,735评论 0 5
  • 2010年上海世博会排长龙进场馆的景象还历历在目。 作为一位产品经理,不自觉就考虑起「如何让上海迪斯尼不至于太拥挤...
    知行思新阅读 393评论 0 0
  • 你有着霸气的名字,却有着温柔的长相,美的让人怜惜。 老虎花,你选择和热闹的映山红开在同一个时间,却又逃避在荒茫的山...
    木芙蓉花灵阅读 173评论 0 0