Skip to content

Commit 2040a0f

Browse files
author
Antoine Lelievre
committed
Removed obsolete code and bumped package version
1 parent 437fa17 commit 2040a0f

4 files changed

Lines changed: 25 additions & 41 deletions

File tree

Editor/Utils/NodeProvider.cs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Editor/Views/BaseGraphView.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,6 @@ void MouseDownCallback(MouseDownEvent e)
411411
{
412412
// Close all settings windows:
413413
nodeViews.ForEach(v => v.CloseSettings());
414-
415-
if (e.clickCount == 2)
416-
{
417-
RegisterCompleteObjectUndo("Added relay node ");
418-
Vector2 mousePos = (e.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, e.localMousePosition);
419-
AddNode(BaseNode.CreateFromType<RelayNode>(mousePos));
420-
}
421414
}
422415
}
423416

Editor/Views/BaseNodeView.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,22 +398,18 @@ public void AlignToBottom()
398398

399399
public void OpenNodeViewScript()
400400
{
401-
var scriptPath = NodeProvider.GetNodeViewScript(GetType());
401+
var script = NodeProvider.GetNodeViewScript(GetType());
402402

403-
#pragma warning disable CS0618 // Deprecated function but no alternative :(
404-
if (scriptPath != null)
405-
InternalEditorUtility.OpenFileAtLineExternal(scriptPath, 0);
406-
#pragma warning restore CS0618
403+
if (script != null)
404+
AssetDatabase.OpenAsset(script.GetInstanceID(), 0, 0);
407405
}
408406

409407
public void OpenNodeScript()
410408
{
411-
var scriptPath = NodeProvider.GetNodeScript(nodeTarget.GetType());
409+
var script = NodeProvider.GetNodeScript(nodeTarget.GetType());
412410

413-
#pragma warning disable CS0618 // Deprecated function but no alternative :(
414-
if (scriptPath != null)
415-
InternalEditorUtility.OpenFileAtLineExternal(scriptPath, 0);
416-
#pragma warning restore CS0618
411+
if (script != null)
412+
AssetDatabase.OpenAsset(script.GetInstanceID(), 0, 0);
417413
}
418414

419415
public void ToggleDebug()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.alelievr.node-graph-processor",
33
"displayName": "Node Graph Processor",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"unity": "2019.3",
66
"description": "Node graph editor framework focused on data processing using Unity UIElements and C# 4.7",
77
"keywords": [

0 commit comments

Comments
 (0)