批量转换Texture为Sprite

批量转换Texture为Sprite批量将贴图 Texture 转换为精灵 Sprite 在 project 视图 选中多张 Texture 菜单栏 Tool ConvertTextu 点击按钮 public class TextureConve MenuItem

大家好,我是讯享网,很高兴认识大家。


讯享网

 public class TextureConvertToSprite { [MenuItem("Tool/ConvertTextureToSprite")] static void ConvertToSprite() { //获取所有被选中的物体 System.Object[] selection = (System.Object[])Selection.objects; //合法性处理 if (selection.Length == 0) { return; } //批量导入贴图 foreach (System.Object obj in selection) { //取得每一张贴图 Texture texture = obj as Texture; //获得贴图路径 string localpath = AssetDatabase.GetAssetPath(texture); //贴图导入 TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(localpath); //设置贴图类型 importer.textureType = TextureImporterType.Sprite; //导入项目资源 AssetDatabase.ImportAsset(localpath); } //刷新项目资源 AssetDatabase.Refresh(); } } 

讯享网
小讯
上一篇 2025-04-09 22:25
下一篇 2025-02-07 10:28

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/12724.html