diff --git a/Scripts/Editor/NodeEditorReflection.cs b/Scripts/Editor/NodeEditorReflection.cs
index d1f3c0a..6cdbc42 100644
--- a/Scripts/Editor/NodeEditorReflection.cs
+++ b/Scripts/Editor/NodeEditorReflection.cs
@@ -11,10 +11,12 @@ namespace XNodeEditor {
public partial class NodeEditorWindow {
/// Custom node tint colors defined with [NodeColor(r, g, b)]
public static Dictionary nodeTint { get { return _nodeTint != null ? _nodeTint : _nodeTint = GetNodeTint(); } }
- [NonSerialized] private static Dictionary _nodeTint;
+
+ [NonSerialized] private static Dictionary _nodeTint;
/// All available node types
public static Type[] nodeTypes { get { return _nodeTypes != null ? _nodeTypes : _nodeTypes = GetNodeTypes(); } }
- [NonSerialized] private static Type[] _nodeTypes = null;
+
+ [NonSerialized] private static Type[] _nodeTypes = null;
public static Type[] GetNodeTypes() {
//Get all classes deriving from Node via reflection
@@ -32,13 +34,14 @@ namespace XNodeEditor {
return tints;
}
+ /// Get all classes deriving from baseType via reflection
public static Type[] GetDerivedTypes(Type baseType) {
- //Get all classes deriving from baseType via reflection
- Assembly assembly = Assembly.GetAssembly(baseType);
- return assembly.GetTypes().Where(t =>
- !t.IsAbstract &&
- baseType.IsAssignableFrom(t)
- ).ToArray();
+ List types = new List();
+ System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
+ foreach (Assembly assembly in assemblies) {
+ types.AddRange(assembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t)).ToArray());
+ }
+ return types.ToArray();
}
public static object ObjectFromType(Type type) {
@@ -71,10 +74,10 @@ namespace XNodeEditor {
kvp.Add(new KeyValuePair(attribs[k], methods[i]));
}
}
- #if UNITY_5_5_OR_NEWER
+#if UNITY_5_5_OR_NEWER
//Sort menu items
kvp.Sort((x, y) => x.Key.priority.CompareTo(y.Key.priority));
- #endif
+#endif
return kvp.ToArray();
}
diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs
index acffe69..23507a6 100644
--- a/Scripts/NodeDataCache.cs
+++ b/Scripts/NodeDataCache.cs
@@ -46,13 +46,19 @@ namespace XNode {
private static void BuildCache() {
portDataCache = new PortDataCache();
System.Type baseType = typeof(Node);
- Assembly assembly = Assembly.GetAssembly(baseType);
- System.Type[] nodeTypes = assembly.GetTypes().Where(t =>
- !t.IsAbstract &&
- baseType.IsAssignableFrom(t)
- ).ToArray();
-
- for (int i = 0; i < nodeTypes.Length; i++) {
+ List nodeTypes = new List();
+ System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
+ Assembly selfAssembly = Assembly.GetAssembly(baseType);
+ if (selfAssembly.FullName.StartsWith("Assembly-CSharp")) {
+ // If xNode is not used as a DLL, check only CSharp (fast)
+ nodeTypes.AddRange(selfAssembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t)));
+ } else {
+ // Else, check all DDLs (slow)
+ foreach (Assembly assembly in assemblies) {
+ nodeTypes.AddRange(assembly.GetTypes().Where(t => !t.IsAbstract && baseType.IsAssignableFrom(t)).ToArray());
+ }
+ }
+ for (int i = 0; i < nodeTypes.Count; i++) {
CachePorts(nodeTypes[i]);
}
}
@@ -103,4 +109,4 @@ namespace XNode {
}
}
}
-}
+}
\ No newline at end of file