/// <summary> /// Recursively locates all plugins in the specified folder, appending to the incoming list /// </summary> /// <param name="PluginsDirectory">Directory to search</param> /// <param name="LoadedFrom">Where we're loading these plugins from</param> /// <param name="Plugins">List of plugins found so far</param> private static void FindPluginsRecursively(string PluginsDirectory, PluginInfo.LoadedFromType LoadedFrom, ref List <PluginInfo> Plugins) { // NOTE: The logic in this function generally matches that of the C++ code for FindPluginsRecursively // in the core engine code. These routines should be kept in sync. // Each sub-directory is possibly a plugin. If we find that it contains a plugin, we won't recurse any // further -- you can't have plugins within plugins. If we didn't find a plugin, we'll keep recursing. var PluginsDirectoryInfo = new DirectoryInfo(PluginsDirectory); foreach (var PossiblePluginDirectory in PluginsDirectoryInfo.EnumerateDirectories()) { if (!UnrealBuildTool.IsPathIgnoredForBuild(PossiblePluginDirectory.FullName)) { // Do we have a plugin descriptor in this directory? bool bFoundPlugin = false; foreach (var PluginDescriptorFileName in Directory.GetFiles(PossiblePluginDirectory.FullName, "*" + PluginDescriptorFileExtension)) { // Found a plugin directory! No need to recurse any further, but make sure it's unique. if (!Plugins.Any(x => x.Directory == PossiblePluginDirectory.FullName)) { // Load the plugin info and keep track of it var PluginDescriptorFile = new FileInfo(PluginDescriptorFileName); var PluginInfo = LoadPluginDescriptor(PluginDescriptorFile, LoadedFrom); Plugins.Add(PluginInfo); bFoundPlugin = true; Log.TraceVerbose("Found plugin in: " + PluginInfo.Directory); } // No need to search for more plugins break; } if (!bFoundPlugin) { // Didn't find a plugin in this directory. Continue to look in subfolders. FindPluginsRecursively(PossiblePluginDirectory.FullName, LoadedFrom, ref Plugins); } } } }