Skip to content

Commit f57da70

Browse files
author
Stewart Miles
committed
Fixed Version Handler asset rename.
When a file is moved between folders AssetDatabase.RenameAsset() does nothing and doesn't return an error so try using AssetDatabase.MoveAsset() first and fallback to RenameAsset() if that fails. Bug: 127793909 Change-Id: Ie8801c4ef5c76b45b00e83a280b5b7dba5f99069
1 parent 76931c2 commit f57da70

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

source/VersionHandlerImpl/src/VersionHandlerImpl.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,13 @@ public bool RenameAsset(string newFilename) {
746746
}
747747
try {
748748
// This is *really* slow.
749-
string error = AssetDatabase.RenameAsset(
750-
filename, filenameComponents.basenameNoExtension);
749+
string error = AssetDatabase.MoveAsset(filename, newFilename);
750+
if (!String.IsNullOrEmpty(error)) {
751+
string renameError = AssetDatabase.RenameAsset(
752+
filename, filenameComponents.basenameNoExtension);
753+
error = String.IsNullOrEmpty(renameError) ?
754+
renameError : String.Format("{0}, {1}", error, renameError);
755+
}
751756
if (!String.IsNullOrEmpty(error)) {
752757
Log("Failed to rename asset " + filename + " to " +
753758
newFilename + " (" + error + ")",

0 commit comments

Comments
 (0)