需要用TextureImporter导入资源,调用如下代码
TextureImporter importer = (TextureImporter)TextureImporter.GetAtPath(path); importer.textureType = TextureImporterType.Sprite; AssetDatabase.Refresh();