Skip to content

Commit

Permalink
Removed obsolete code and bumped package version
Browse files Browse the repository at this point in the history
  • Loading branch information
alelievr committed Mar 28, 2020
1 parent 437fa17 commit 2040a0f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
41 changes: 18 additions & 23 deletions Editor/Utils/NodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace GraphProcessor
{
public static class NodeProvider
{
static Dictionary< Type, Type > nodeViewPerType = new Dictionary< Type, Type >();
static Dictionary< string, Type > nodePerMenuTitle = new Dictionary< string, Type >();
static Dictionary< Type, string > nodeViewScripts = new Dictionary< Type, string >();
static Dictionary< Type, string > nodeScripts = new Dictionary< Type, string >();
static List< Type > slotTypes = new List< Type >();
static Dictionary< Type, Type > nodeViewPerType = new Dictionary< Type, Type >();
static Dictionary< string, Type > nodePerMenuTitle = new Dictionary< string, Type >();
static Dictionary< Type, MonoScript > nodeViewScripts = new Dictionary< Type, MonoScript >();
static Dictionary< Type, MonoScript > nodeScripts = new Dictionary< Type, MonoScript >();
static List< Type > slotTypes = new List< Type >();

static NodeProvider()
{
Expand Down Expand Up @@ -66,18 +66,20 @@ static void AddNodeViewType(Type type)
}
}

static string FindScriptFromClassName(string className)
static MonoScript FindScriptFromClassName(string className)
{
var scriptGUIDs = AssetDatabase.FindAssets(className);
var scriptGUIDs = AssetDatabase.FindAssets($"t:script {className}");

if (scriptGUIDs.Length == 0)
return null;

foreach (var scriptGUID in scriptGUIDs)
{
var assetPath = AssetDatabase.GUIDToAssetPath(scriptGUID);
if (className == Path.GetFileNameWithoutExtension(assetPath))
return assetPath;
var script = AssetDatabase.LoadAssetAtPath<MonoScript>(assetPath);

if (script != null && String.Equals(className, Path.GetFileNameWithoutExtension(assetPath), StringComparison.OrdinalIgnoreCase))
return script;
}

return null;
Expand Down Expand Up @@ -105,27 +107,20 @@ public static Dictionary< string, Type > GetNodeMenuEntries()
return nodePerMenuTitle;
}

public static string GetNodeViewScript(Type type)
public static MonoScript GetNodeViewScript(Type type)
{
string scriptPath;

nodeViewScripts.TryGetValue(type, out scriptPath);
nodeViewScripts.TryGetValue(type, out var script);

return scriptPath;
return script;
}

public static string GetNodeScript(Type type)
public static MonoScript GetNodeScript(Type type)
{
string scriptPath;

nodeScripts.TryGetValue(type, out scriptPath);
nodeScripts.TryGetValue(type, out var script);

return scriptPath;
return script;
}

public static List<Type> GetSlotTypes()
{
return slotTypes;
}
public static List<Type> GetSlotTypes() => slotTypes;
}
}
7 changes: 0 additions & 7 deletions Editor/Views/BaseGraphView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,6 @@ void MouseDownCallback(MouseDownEvent e)
{
// Close all settings windows:
nodeViews.ForEach(v => v.CloseSettings());

if (e.clickCount == 2)
{
RegisterCompleteObjectUndo("Added relay node ");
Vector2 mousePos = (e.currentTarget as VisualElement).ChangeCoordinatesTo(contentViewContainer, e.localMousePosition);
AddNode(BaseNode.CreateFromType<RelayNode>(mousePos));
}
}
}

Expand Down
16 changes: 6 additions & 10 deletions Editor/Views/BaseNodeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,22 +398,18 @@ public void AlignToBottom()

public void OpenNodeViewScript()
{
var scriptPath = NodeProvider.GetNodeViewScript(GetType());
var script = NodeProvider.GetNodeViewScript(GetType());

#pragma warning disable CS0618 // Deprecated function but no alternative :(
if (scriptPath != null)
InternalEditorUtility.OpenFileAtLineExternal(scriptPath, 0);
#pragma warning restore CS0618
if (script != null)
AssetDatabase.OpenAsset(script.GetInstanceID(), 0, 0);
}

public void OpenNodeScript()
{
var scriptPath = NodeProvider.GetNodeScript(nodeTarget.GetType());
var script = NodeProvider.GetNodeScript(nodeTarget.GetType());

#pragma warning disable CS0618 // Deprecated function but no alternative :(
if (scriptPath != null)
InternalEditorUtility.OpenFileAtLineExternal(scriptPath, 0);
#pragma warning restore CS0618
if (script != null)
AssetDatabase.OpenAsset(script.GetInstanceID(), 0, 0);
}

public void ToggleDebug()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.alelievr.node-graph-processor",
"displayName": "Node Graph Processor",
"version": "0.5.0",
"version": "0.6.0",
"unity": "2019.3",
"description": "Node graph editor framework focused on data processing using Unity UIElements and C# 4.7",
"keywords": [
Expand Down

0 comments on commit 2040a0f

Please sign in to comment.