Skip to content

Instantly share code, notes, and snippets.

@herpdederp
Created May 19, 2020 19:47
Show Gist options
  • Save herpdederp/9e61724376006352535b63f1ccd0302c to your computer and use it in GitHub Desktop.
Save herpdederp/9e61724376006352535b63f1ccd0302c to your computer and use it in GitHub Desktop.
#if false
[MenuItem("SERVERBUILD/Server/Modes/Server Mode")]
public static void TurnToServerMode()
{
ExcludeFiles(true);
}
[MenuItem("SERVERBUILD/Server/Modes/Client Mode")]
public static void TurnToClientMode()
{
ExcludeFiles(false);
}
private static void ExcludeFiles(bool exclude)
{
const string ROOT_FOLDER = @"Assets";
var excludeExtensions = new[] { ".png", ".jpg", ".mat", ".shader", ".FBX", ".tga", ".wav", ".tif" };
var directories = Directory.GetDirectories(ROOT_FOLDER, "*", SearchOption.AllDirectories);
foreach (var directory in directories)
{
var files = Directory.GetFiles(directory);
foreach (var file in files)
{
var pathExtension = Path.GetExtension(file);
if (!excludeExtensions.Contains(Path.GetExtension(file)) ||
(exclude && file.Contains("~")) || (!exclude && !file.Contains("~"))) continue; // we don't want to exclude these
if (exclude)
File.Move(file, file.Replace(pathExtension, "") + "~" + pathExtension);
else
File.Move(file, file.Replace("~", ""));
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment