-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Additions - Added a generic extension method `Log<T>(this T obj, string format = null, IFormatProvider formatProvider = null)`, which logs `obj.ToString()` using `UnityEngine.Debug.Log()` when using the Unity Editor, `Console.WriteLine()` otherwise - Added some IO/Directory related utility as methods in the static `DirectoryExtensions` class. NOTE: These are subject to change ### Improvements - When using the Unity Editor, the `Window\C# Dev Tools\Manage Safety Checks` window now shows the number of method calls of Assertions that can be enabled/disabled. It is not necessarily 100% accurate. - Made I/O bound task during Unity editor startup asynchronous
- Loading branch information
1 parent
72a8a06
commit aa4c45a
Showing
7 changed files
with
519 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.IO; | ||
|
||
namespace DevTools | ||
{ | ||
public static class DirectoryExtensions | ||
{ | ||
/// <summary> Appends <see cref="Path.DirectorySeparatorChar"/> to '<paramref name="directory"/>' and returns the result. </summary> | ||
public static string AsDirectory(this string directory) | ||
{ | ||
return directory + Path.DirectorySeparatorChar; | ||
} | ||
|
||
/// <summary> Recursively searches for a file '<paramref name="fileName"/>' in the '<paramref name="folder"/>' directory, including subdirectories. </summary> | ||
public static string FindInFolder(string folder, string fileName) | ||
{ | ||
string result = folder.AsDirectory() + fileName; | ||
if (File.Exists(result)) | ||
{ | ||
return result; | ||
} | ||
|
||
foreach (string subDirectory in Directory.GetDirectories(folder)) | ||
{ | ||
result = FindInFolder(subDirectory, fileName); | ||
if (result != null) | ||
{ | ||
return result; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/// <summary> Deletes a directory '<paramref name="folder"/>' and all of its contents, including subdirectories. </summary> | ||
public static void DeleteFolder(string folder) | ||
{ | ||
foreach (string subFolder in Directory.GetDirectories(folder)) | ||
{ | ||
DeleteFolder(subFolder); | ||
} | ||
|
||
foreach (string file in Directory.GetFiles(folder)) | ||
{ | ||
File.Delete(file); | ||
} | ||
|
||
Directory.Delete(folder); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
|
||
namespace DevTools | ||
{ | ||
public static class GenericExtensions | ||
{ | ||
/// <summary> Logs a message of type '<typeparamref name="T"/>' to the console. </summary> | ||
public static void Log<T>(this T obj) | ||
{ | ||
#if DEBUG | ||
#if UNITY_EDITOR | ||
UnityEngine.Debug.Log(obj); | ||
#else | ||
Console.WriteLine(obj); | ||
#endif | ||
#endif | ||
} | ||
|
||
/// <summary> Logs a message of type '<typeparamref name="T"/>' to the console. </summary> | ||
public static void Log<T>(this T obj, string format, IFormatProvider formatProvider = null) | ||
where T : IFormattable | ||
{ | ||
Log(obj.ToString(format, formatProvider)); | ||
} | ||
} | ||
} |
Oops, something went wrong.