Skip to content

Commit 08a7e87

Browse files
authored
Add log when Unity failed to create folder (#549)
* Add log when Unity failed to create folder Follow up for #543. When Unity failed to create folder using Unity API `AssetDatabase.CreateFolder()`, even with the workaround in #543, Unity would still generate two error message and there is no way to turn it off. This change add an additional log after Unity API fails to inform the user to ignore this error.
1 parent 6d06c69 commit 08a7e87

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Diff for: source/AndroidResolver/src/PlayServicesResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ internal static string CopyAssetAndLabel(string sourceLocation, string targetLoc
24682468
}
24692469

24702470
var targetDir = Path.GetDirectoryName(targetLocation);
2471-
if (!FileUtils.CreateFolder(targetDir)) {
2471+
if (!FileUtils.CreateFolder(targetDir, logger)) {
24722472
return String.Format("Failed to create folders at {0}", targetDir);
24732473
}
24742474

Diff for: source/VersionHandlerImpl/src/FileUtils.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ internal static bool IsValidGuid(string guidStr) {
639639
/// </summary>
640640
/// <param name="path">Path to the file/directory that needs checking.</param>
641641
/// <returns>True if all folders are created successfully.</returns>
642-
public static bool CreateFolder(string path) {
642+
public static bool CreateFolder(string path, Google.Logger logger = null) {
643643
if (AssetDatabase.IsValidFolder(path)) {
644644
return true;
645645
}
@@ -656,6 +656,20 @@ public static bool CreateFolder(string path) {
656656
return true;
657657
}
658658

659+
if (logger != null) {
660+
logger.Log(
661+
String.Format(
662+
"Please ignore Unity error messages similar to '{0}'.\n" +
663+
"Unable to use Unity API `AssetDatabase.CreateFolder()` to " +
664+
"create folder: '{1}'. Switch to use `Directory.CreateDirectory()` " +
665+
"instead. \n\n" +
666+
"See {2} for more information.",
667+
"*** is not a valid directory name.",
668+
path,
669+
"https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-7046"),
670+
LogLevel.Info);
671+
}
672+
659673
return Directory.CreateDirectory(path) != null;
660674
}
661675

0 commit comments

Comments
 (0)