Unity_将导入的图片自动设置为Sprite图片

1.在根目录下创建一个Editor文件夹 之后在Editor文件夹下创建一个脚本 TextureChage

2.TextureChange的代码如下

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
//精灵图片导入器
public class TextureChange : AssetPostprocessor
{
    private void OnPreprocessTexture() {
        //引入assetImporter(所有导入器的父类)转换为TextureImporter导入器
        TextureImporter importer = (TextureImporter)assetImporter;
        //将所有导入图片设置成 Spritre 类型
        importer.textureType = TextureImporterType.Sprite;
    }
}

之后导入一张图片进行测试 发现纹理类型 自动变成Sprite格式了

猜你喜欢

转载自blog.csdn.net/weixin_42137574/article/details/108405534