当前位置:Gxlcms >
数据库问题 >
AssetDatabase.RenameAsset 重命名文件失败
AssetDatabase.RenameAsset 重命名文件失败
时间:2021-07-01 10:21:17
帮助过:26人阅读
[MenuItem(
"Edit/Transform Texture To Dither")]
2 static void SetSelectTextureToDither()
3 {
4 foreach(Object obj
in Selection.GetFiltered(
typeof(Object), SelectionMode.Assets))
5 {
6 string path = path =
AssetDatabase.GetAssetPath(obj); ;
7 TextureImporter textureImporter = AssetImporter.GetAtPath(path)
as TextureImporter;
8 if (textureImporter ==
null)
9 continue;
10
11 textureImporter.textureFormat =
TextureImporterFormat.AutomaticTruecolor;
12 textureImporter.mipmapEnabled =
false;
13
14 AssetDatabase.WriteImportSettingsIfDirty(path);
15 string newPathName = Path.GetFileNameWithoutExtension(path) +
".Dither";
16 string renameRes =
AssetDatabase.RenameAsset(path, newPathName);
17 if (renameRes !=
"")
18 Debug.Log(
"Fail to rename, err: " +
renameRes);
19 AssetDatabase.WriteImportSettingsIfDirty(newPathName);
20 }
21 Debug.Log(
"Complete transform Texture to Dither!!");
22 }
AssetDatabase.RenameAsset 重命名文件失败
标签: