Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions ModTool.Editor.Exporting/ExportStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private List<Asset> GetAssets(string filter)
{
string path = AssetDatabase.GUIDToAssetPath(guid);

if (path.Contains("/ModTool/") || path.Contains("/Editor/"))
if (path.Contains("/ModTool/") || path.Contains("/Editor/") || path.Contains("/External/"))
continue;

if (path.StartsWith("Packages"))
Expand All @@ -330,19 +330,49 @@ private List<Asset> GetAssets(string filter)
return assets;
}

//generate a hashset of assembly names that are from other mods
private HashSet<string> FindIgnoredAssemblies()
{
List<Asset> assets = new List<Asset>();

string[] guids = AssetDatabase.FindAssets("t:asmdef");

HashSet<string> ignoredAssemblies = new HashSet<string>();

foreach (string guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if(path.Contains("/External/"))
ignoredAssemblies.Add(Path.GetFileNameWithoutExtension(path));
}

return ignoredAssemblies;
}

private List<Asset> GetAssemblies()
{
List<Asset> assemblies = new List<Asset>();

foreach (string path in AssemblyUtility.GetAssemblies(assetsDirectory))
HashSet<string> ignoredSet = FindIgnoredAssemblies();

foreach (string path in AssemblyUtility.GetAssemblies(assetsDirectory, IsIgnored(ignoredSet, false)))
assemblies.Add(new Asset(path));

foreach (string path in AssemblyUtility.GetAssemblies(assemblyDirectory, IsModAssembly))
foreach (string path in AssemblyUtility.GetAssemblies(assemblyDirectory, IsIgnored(ignoredSet, true)))
assemblies.Add(new Asset(path));

return assemblies;
}

//generate a filter based on ignoredSet. if ignoredSet does not contain assembly name and it passes IsModAssembly, return true
private Func<string, bool> IsIgnored(HashSet<string> ignored, bool IsModAssemblyCheck)
{
if(IsModAssemblyCheck)
return assembly => !ignored.Contains(Path.GetFileNameWithoutExtension(assembly)) && IsModAssembly(assembly);

return assembly => !ignored.Contains(Path.GetFileNameWithoutExtension(assembly));
}

private bool IsModAssembly(string assembly)
{
string name = Path.GetFileNameWithoutExtension(assembly);
Expand Down