Skip to content

Commit

Permalink
fix: #14 The "Select Node" menu has merged options with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarianZ committed Apr 7, 2023
1 parent 774e048 commit 1601b5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
28 changes: 21 additions & 7 deletions Editor/Scripts/Window/PlayableGraphMonitorWindow_Toolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ private void OnHoverSelectOutputNodeMenu(PointerEnterEvent evt)
var playableGraph = _graphPopupField.value;
if (!playableGraph.IsValid())
{
_selectOutputNodeMenu.menu.AppendAction("No PlayableOuput node", null,
DropdownMenuAction.Status.Disabled);
return;
}

Expand All @@ -276,15 +278,21 @@ private void OnHoverSelectOutputNodeMenu(PointerEnterEvent evt)
continue;
}

var nodeName = $"{outputNode.PlayableOutput.GetPlayableOutputType().Name}" +
$" ({outputNode.PlayableOutput.GetEditorName()})";
var nodeName = $"#{i} [{outputNode.PlayableOutput.GetEditorName()}]" +
$" {outputNode.PlayableOutput.GetPlayableOutputType().Name}";
_selectOutputNodeMenu.menu.AppendAction(nodeName, _ =>
{
_graphView.ClearSelection();
_graphView.AddToSelection(outputNode);
_graphView.FrameSelection();
});
}

if (outputCount == 0)
{
_selectOutputNodeMenu.menu.AppendAction("No PlayableOuput node", null,
DropdownMenuAction.Status.Disabled);
}
}

private void OnHoverSelectRootNodeMenu(PointerEnterEvent evt)
Expand All @@ -294,6 +302,8 @@ private void OnHoverSelectRootNodeMenu(PointerEnterEvent evt)
var playableGraph = _graphPopupField.value;
if (!playableGraph.IsValid())
{
_selectRootNodeMenu.menu.AppendAction("No root Playable node", null,
DropdownMenuAction.Status.Disabled);
return;
}

Expand All @@ -320,11 +330,9 @@ private void OnHoverSelectRootNodeMenu(PointerEnterEvent evt)
continue;
}

var nodeName = $"{playableNode.Playable.GetPlayableType()?.Name ?? "?"}";
if (!string.IsNullOrEmpty(playableNode.ExtraLabel))
{
nodeName = $"{nodeName} ({playableNode.ExtraLabel})";
}
var nodeName = !string.IsNullOrEmpty(playableNode.ExtraLabel)
? $"#{i} [{playableNode.ExtraLabel}] {playableNode.Playable.GetPlayableType().Name}"
: $"#{i} {playableNode.Playable.GetPlayableType().Name}";

_selectRootNodeMenu.menu.AppendAction(nodeName, _ =>
{
Expand All @@ -333,6 +341,12 @@ private void OnHoverSelectRootNodeMenu(PointerEnterEvent evt)
_graphView.FrameSelection();
});
}

if (rootPlayableCount == 0)
{
_selectRootNodeMenu.menu.AppendAction("No root Playable node", null,
DropdownMenuAction.Status.Disabled);
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.greenbamboogames.playablegraphmonitor",
"version": "2.5.0",
"version": "2.5.1",
"displayName": "PlayableGraph Monitor!",
"description": "PlayableGraph monitor.",
"unity": "2019.4",
Expand Down

0 comments on commit 1601b5f

Please sign in to comment.