Skip to content

Commit 3e63f71

Browse files
committed
Changed the code to make it work with version 5.6.0b5
1 parent 1efed16 commit 3e63f71

23 files changed

+389
-202
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine.Experimental.Director;
5+
6+
// Bridge between runtime and editor code: the graph created in runtime code can call GraphVisualizerClient.Show(...)
7+
// and the EditorWindow will register itself with the client to display any available graph.
8+
public class GraphVisualizerClient
9+
{
10+
private static GraphVisualizerClient s_Instance;
11+
private Dictionary<PlayableGraph, string> m_Graphs = new Dictionary<PlayableGraph, string>();
12+
13+
public static GraphVisualizerClient instance
14+
{
15+
get
16+
{
17+
if (s_Instance == null)
18+
s_Instance = new GraphVisualizerClient();
19+
return s_Instance;
20+
}
21+
}
22+
~GraphVisualizerClient()
23+
{
24+
m_Graphs.Clear();
25+
}
26+
public static void Show(PlayableGraph graph, string name)
27+
{
28+
if (!instance.m_Graphs.ContainsKey(graph))
29+
{
30+
instance.m_Graphs.Add(graph, name);
31+
}
32+
}
33+
public static void Hide(PlayableGraph graph)
34+
{
35+
if (instance.m_Graphs.ContainsKey(graph))
36+
{
37+
instance.m_Graphs.Remove(graph);
38+
}
39+
}
40+
41+
public static IEnumerable<KeyValuePair<PlayableGraph, string>> GetGraphs()
42+
{
43+
return instance.m_Graphs;
44+
}
45+
}

Assets/Clients/GraphVisualizerClient.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph/Graph.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,10 @@ IEnumerator IEnumerable.GetEnumerator()
6666
{
6767
return m_Nodes.GetEnumerator();
6868
}
69+
70+
public bool IsEmpty()
71+
{
72+
return m_Nodes.Count == 0;
73+
}
6974
}
7075
}

Assets/Editor/GraphVisualizer/Graph/Graph.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph/Layouts.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph/Layouts/IGraphLayout.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph/Layouts/ReingoldTilford.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ private float[] ComputeHorizontalPositionForEachLevel()
9797
nodes.Add(node);
9898
maxDepth = Mathf.Max(d, maxDepth);
9999
}
100-
100+
101101
// Bake the left to right horizontal positions.
102102
var horizontalPositionForDepth = new float[maxDepth];
103103
horizontalPositionForDepth[0] = 0;
104104
for (int d = 1; d < maxDepth; ++d)
105105
{
106-
IEnumerable<Node> nodesOnThisLevel = nodeDepths[d+1];
106+
IEnumerable<Node> nodesOnThisLevel = nodeDepths[d + 1];
107107

108108
int maxChildren = nodesOnThisLevel.Max(x => x.children.Count);
109109

Assets/Editor/GraphVisualizer/Graph/Layouts/ReingoldTilford.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/GraphVisualizer/Graph/Node.cs.meta

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)