mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Nostek's fix for #175
This commit is contained in:
parent
5bc267d23b
commit
8b2b2425d1
@ -64,25 +64,18 @@ namespace XNode {
|
|||||||
|
|
||||||
private static void BuildCache() {
|
private static void BuildCache() {
|
||||||
portDataCache = new PortDataCache();
|
portDataCache = new PortDataCache();
|
||||||
System.Type baseType = typeof(Node);
|
|
||||||
List<System.Type> nodeTypes = new List<System.Type>();
|
List<System.Type> nodeTypes = new List<System.Type>();
|
||||||
System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
|
System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
|
||||||
Assembly selfAssembly = Assembly.GetAssembly(baseType);
|
string dataPath = System.IO.Directory.GetParent(Application.dataPath).FullName; //We need the parent folder of 'dataPath' and converted to the OS specific directory specifications.
|
||||||
if (selfAssembly.FullName.StartsWith("Assembly-CSharp") && !selfAssembly.FullName.Contains("-firstpass")) {
|
foreach (Assembly assembly in assemblies) {
|
||||||
// If xNode is not used as a DLL, check only CSharp (fast)
|
if (assembly.ManifestModule is System.Reflection.Emit.ModuleBuilder) continue; //we don't want to check dynamics and dynamics does not have a location for our next test.
|
||||||
nodeTypes.AddRange(selfAssembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t)));
|
if (!assembly.Location.StartsWith(dataPath)) continue; //we only care about assemblies that exists in our project directory.
|
||||||
} else {
|
|
||||||
// Else, check all relevant DDLs (slower)
|
System.Type[] types = assembly.GetExportedTypes();
|
||||||
// ignore all unity related assemblies
|
foreach (var t in types) {
|
||||||
// never ignore current executing assembly
|
if (t.IsAbstract) continue;
|
||||||
Assembly executingAssembly = Assembly.GetExecutingAssembly();
|
if (!typeof(Node).IsAssignableFrom(t)) continue;
|
||||||
foreach (Assembly assembly in assemblies) {
|
nodeTypes.Add(t);
|
||||||
if(assembly != executingAssembly) {
|
|
||||||
if (assembly.FullName.StartsWith("Unity")) continue;
|
|
||||||
// unity created assemblies always have version 0.0.0
|
|
||||||
if (!assembly.FullName.Contains("Version=0.0.0")) continue;
|
|
||||||
}
|
|
||||||
nodeTypes.AddRange(assembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t)).ToArray());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nodeTypes.Count; i++) {
|
for (int i = 0; i < nodeTypes.Count; i++) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user