root namespaceしか変わってない場合はファイルを消さない

This commit is contained in:
naninunenoy 2021-10-13 01:41:33 +09:00
parent 7669aa0212
commit 7f311b9000

View File

@ -56,6 +56,7 @@ namespace AsmdefHelper.CustomCreate.Editor {
// 既存パラメータの反映 // 既存パラメータの反映
pathTextField.value = asmdefDirectory; pathTextField.value = asmdefDirectory;
nameTextField.value = asmdef.name; nameTextField.value = asmdef.name;
var asmdefNameOrg = asmdef.name;
// RootNamespace が設定できるのは2020.2以降 // RootNamespace が設定できるのは2020.2以降
#if UNITY_2020_2_OR_NEWER #if UNITY_2020_2_OR_NEWER
@ -75,8 +76,10 @@ namespace AsmdefHelper.CustomCreate.Editor {
var newAsmdefPath = $"{asmdefDirectory}/{asmdefName}.asmdef"; var newAsmdefPath = $"{asmdefDirectory}/{asmdefName}.asmdef";
// 新asmdef作成 // 新asmdef作成
File.WriteAllText(newAsmdefPath, asmdefJson, Encoding.UTF8); File.WriteAllText(newAsmdefPath, asmdefJson, Encoding.UTF8);
// 旧asmdef削除 // ファイル名が変わった場合は旧asmdef削除
File.Delete(renameAsmdefPath); if (asmdefNameOrg != asmdefName) {
FileUtil.DeleteFileOrDirectory(renameAsmdefPath);
}
AssetDatabase.Refresh(); AssetDatabase.Refresh();
Close(); Close();
}; };