@@ -12,11 +12,11 @@ namespace GraphProcessor
1212{
1313 public static class NodeProvider
1414 {
15- static Dictionary < Type , Type > nodeViewPerType = new Dictionary < Type , Type > ( ) ;
16- static Dictionary < string , Type > nodePerMenuTitle = new Dictionary < string , Type > ( ) ;
17- static Dictionary < Type , string > nodeViewScripts = new Dictionary < Type , string > ( ) ;
18- static Dictionary < Type , string > nodeScripts = new Dictionary < Type , string > ( ) ;
19- static List < Type > slotTypes = new List < Type > ( ) ;
15+ static Dictionary < Type , Type > nodeViewPerType = new Dictionary < Type , Type > ( ) ;
16+ static Dictionary < string , Type > nodePerMenuTitle = new Dictionary < string , Type > ( ) ;
17+ static Dictionary < Type , MonoScript > nodeViewScripts = new Dictionary < Type , MonoScript > ( ) ;
18+ static Dictionary < Type , MonoScript > nodeScripts = new Dictionary < Type , MonoScript > ( ) ;
19+ static List < Type > slotTypes = new List < Type > ( ) ;
2020
2121 static NodeProvider ( )
2222 {
@@ -66,18 +66,20 @@ static void AddNodeViewType(Type type)
6666 }
6767 }
6868
69- static string FindScriptFromClassName ( string className )
69+ static MonoScript FindScriptFromClassName ( string className )
7070 {
71- var scriptGUIDs = AssetDatabase . FindAssets ( className ) ;
71+ var scriptGUIDs = AssetDatabase . FindAssets ( $ "t:script { className } " ) ;
7272
7373 if ( scriptGUIDs . Length == 0 )
7474 return null ;
7575
7676 foreach ( var scriptGUID in scriptGUIDs )
7777 {
7878 var assetPath = AssetDatabase . GUIDToAssetPath ( scriptGUID ) ;
79- if ( className == Path . GetFileNameWithoutExtension ( assetPath ) )
80- return assetPath ;
79+ var script = AssetDatabase . LoadAssetAtPath < MonoScript > ( assetPath ) ;
80+
81+ if ( script != null && String . Equals ( className , Path . GetFileNameWithoutExtension ( assetPath ) , StringComparison . OrdinalIgnoreCase ) )
82+ return script ;
8183 }
8284
8385 return null ;
@@ -105,27 +107,20 @@ public static Dictionary< string, Type > GetNodeMenuEntries()
105107 return nodePerMenuTitle ;
106108 }
107109
108- public static string GetNodeViewScript ( Type type )
110+ public static MonoScript GetNodeViewScript ( Type type )
109111 {
110- string scriptPath ;
111-
112- nodeViewScripts . TryGetValue ( type , out scriptPath ) ;
112+ nodeViewScripts . TryGetValue ( type , out var script ) ;
113113
114- return scriptPath ;
114+ return script ;
115115 }
116116
117- public static string GetNodeScript ( Type type )
117+ public static MonoScript GetNodeScript ( Type type )
118118 {
119- string scriptPath ;
120-
121- nodeScripts . TryGetValue ( type , out scriptPath ) ;
119+ nodeScripts . TryGetValue ( type , out var script ) ;
122120
123- return scriptPath ;
121+ return script ;
124122 }
125123
126- public static List < Type > GetSlotTypes ( )
127- {
128- return slotTypes ;
129- }
124+ public static List < Type > GetSlotTypes ( ) => slotTypes ;
130125 }
131126}
0 commit comments