Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Editor/PlayableGraphVisualizerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ private PlayableGraph GetSelectedGraphInToolBar(List<PlayableGraph> graphs, Play
List<string> options = new List<string>(graphs.Count);
foreach (var graph in graphs)
{
string name = graph.GetEditorName();
string name = GraphVisualizerClient.GetName(graph);
if (name == null)
{
name = graph.GetEditorName();
}
options.Add(name.Length != 0 ? name : "[Unnamed]");
}

options.Sort();

int currentSelection = graphs.IndexOf(currentGraph);
int newSelection = EditorGUILayout.Popup(currentSelection != -1 ? currentSelection : 0, options.ToArray(), GUILayout.Width(200));

Expand Down
26 changes: 22 additions & 4 deletions Runtime/GraphVisualizerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class GraphVisualizerClient
{
private static GraphVisualizerClient s_Instance;
private List<PlayableGraph> m_Graphs = new List<PlayableGraph>();
private Dictionary<PlayableGraph, string> m_GraphNames = new Dictionary<PlayableGraph, string>();

public static GraphVisualizerClient instance
{
Expand All @@ -24,19 +25,27 @@ public static GraphVisualizerClient instance
}

public static void Show(PlayableGraph graph)
{
#if UNITY_EDITOR
Show(graph, graph.GetEditorName());
#else
Show(graph, null);
#endif
}

public static void Show(PlayableGraph graph, string name)
{
if (!instance.m_Graphs.Contains(graph))
{
instance.m_Graphs.Add(graph);
}
instance.m_GraphNames[graph] = name;
}

public static void Hide(PlayableGraph graph)
{
if (instance.m_Graphs.Contains(graph))
{
instance.m_Graphs.Remove(graph);
}
instance.m_Graphs.Remove(graph);
instance.m_GraphNames.Remove(graph);
}

public static void ClearGraphs()
Expand All @@ -48,4 +57,13 @@ public static IEnumerable<PlayableGraph> GetGraphs()
{
return instance.m_Graphs;
}

public static string GetName(PlayableGraph graph)
{
if (instance.m_GraphNames.TryGetValue(graph, out var name))
{
return name;
}
return null;
}
}