概要
UE5.7で検証しています
UE5で開発しているとVisualStudio君が非常に重たいです。
対策として単純にソースコードを減らす事でインテリセンスなどの負荷を下げられないかという検証です。
気持ち軽量になった気がしますが、実測などは行っていない為、適応する場合には自己責任でお願いします
有用な実装な場合は公式で実装して欲しいです。
なお、実装が汚いのでプルリクエストは出しません
| 未改造で作成したUE5.vcxproj | 改造後で生成したUE5.vcxproj |
|---|---|
![]() |
![]() |
反映した所、ファイルサイズは半分ほど減りました。
UnrealBuildToolを改造
Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs
上記のファイルを2か所修正を入れる必要があります。
修正後にEngine\Binaries\DotNET\UnrealBuildToolを削除して再生成すれば反映されます。
public virtual bool GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, string[] Arguments, ILogger Logger)
{
// ---------------------------------------------
// 省略
// Find all of the module files. This will filter out any modules or targets that don't belong to platforms
// we're generating project files for.
List<FileReference> AllModuleFiles = DiscoverModules(CodeBasedGameProjects, AdditionalSearchPaths.Values.SelectMany(x => x).ToList());
// ここで除外が必要か?
// Build.csファイルがリストアップしている
// OnlyGameProjectDescriptorが存在する場合にはuprojectが指定されているはず...
if(OnlyGameProjectDescriptor != null)
{
bool IsEnablePlugins(FileReference ModuleFile)
{
// プラグイン以外のコードは見逃す
if(!ModuleFile.Directory.FullName.Contains("Engine\\Plugins"))
{
return true;
}
DirectoryReference? CurrentDir = ModuleFile.Directory;
FileReference? PluginFile = null;
while (CurrentDir != null && !CurrentDir.IsRootDirectory())
{
// .upluginファイルを探す
IEnumerable<FileReference> UpluginFiles = DirectoryReference.EnumerateFiles(CurrentDir, "*.uplugin");
if (UpluginFiles.Any())
{
PluginFile = UpluginFiles.First();
break;
}
CurrentDir = CurrentDir.ParentDirectory;
}
// 一旦プラグインファイルが見つからなければ有効とする
if (PluginFile == null)
{
return true;
}
bool bEnablePlugin = false;
// プラグインのデフォルト状態
PluginDescriptor pluginDescriptor = PluginDescriptor.FromFile(PluginFile);
if (pluginDescriptor != null && pluginDescriptor.bEnabledByDefault != null)
{
bEnablePlugin = (bool)pluginDescriptor.bEnabledByDefault;
}
string PluginName = PluginFile.GetFileNameWithoutExtension();
PluginReferenceDescriptor? PluginReference = OnlyGameProjectDescriptor?.Plugins?.FirstOrDefault(x => x.Name == PluginName);
if (PluginReference != null)
{
bEnablePlugin = PluginReference.bEnabled;
}
// プラグインが無効ならスキップ
if (!bEnablePlugin)
{
return false;
}
return true;
}
int PrevCount = AllModuleFiles.Count;
AllModuleFiles = AllModuleFiles.Where(IsEnablePlugins).ToList();
int NewCount = AllModuleFiles.Count;
if(PrevCount != NewCount)
{
Logger.Log(LogLevel.Information, $"Skip Plugins Count: {PrevCount} => {NewCount}");
}
}
protected void AddProjectsForAllModules(List<FileReference> AllGames, Dictionary<ProjectFile, FileReference> ProjectFileToUProjectFile, Dictionary<FileReference, ProjectFile> ProgramProjects, List<ProjectFile> ModProjects, List<FileReference> AllModuleFiles, Dictionary<FileReference, List<DirectoryReference>> AdditionalSearchPaths, bool bGatherThirdPartySource, ILogger Logger)
{
// -----------------------------------------------
// 省略
if (added)
{
List<DirectoryReference> plugins = Unreal.GetExtensionDirs(BaseFolder, "Plugins");
if (plugins.Count > 0)
{
foreach (DirectoryReference PluginFolder in plugins)
{
// Add all the plugin files for this project
foreach (FileReference PluginFileName in PluginsBase.EnumeratePlugins(PluginFolder))
{
// ここで除外が必要か?
// OnlyGameProjectDescriptorが存在する場合にはuprojectが指定されているはず...
if (OnlyGameProjectDescriptor != null)
{
//OnlyGameProjectDescriptor.Plugins
bool bEnablePlugin = false;
// プラグインのデフォルト状態
PluginDescriptor pluginDescriptor = PluginDescriptor.FromFile(PluginFileName);
if (pluginDescriptor != null && pluginDescriptor.bEnabledByDefault != null)
{
bEnablePlugin = (bool)pluginDescriptor.bEnabledByDefault;
}
string PluginName = PluginFileName.GetFileNameWithoutExtension();
PluginReferenceDescriptor? PluginReference = OnlyGameProjectDescriptor.Plugins.FirstOrDefault(x => x.Name == PluginName);
if (PluginReference != null)
{
bEnablePlugin = PluginReference.bEnabled;
}
// プラグインが無効ならスキップ
if(!bEnablePlugin)
{
IgnorePlugins.Add(PluginFileName);
Logger.Log(LogLevel.Information, $"Skip Plugins => {PluginName}");
continue;
}
}
if (!ModProjects.Any(x => x.BaseDir == PluginFileName.Directory))
{
PluginsToAdd.Add((PluginFileName, BaseFolder, aProjectFile));
}
}
}
}

