void OnGUI() { // Early out if there is no graphs. var selectedGraphs = GetGraphList(); if (selectedGraphs.Count == 0) { ShowMessage("No PlayableGraph in the scene"); return; } GUILayout.BeginVertical(); m_CurrentGraph = GetSelectedGraphInToolBar(selectedGraphs, m_CurrentGraph); GUILayout.EndVertical(); if (!m_CurrentGraph.IsValid()) { ShowMessage("Selected PlayableGraph is invalid"); return; } var graph = new PlayableGraphVisualizer(m_CurrentGraph); graph.Refresh(); if (graph.IsEmpty()) { ShowMessage("Selected PlayableGraph is empty"); return; } if (m_Layout == null) { m_Layout = new ReingoldTilford(); } m_Layout.CalculateLayout(graph); var graphRect = new Rect(0, s_ToolbarHeight, position.width, position.height - s_ToolbarHeight); if (m_Renderer == null) { m_Renderer = new DefaultGraphRenderer(); } m_Renderer.Draw(m_Layout, graphRect, m_GraphSettings); }
void OnGUI() { // Create a list of all the playable graphs extracted. IList <PlayableGraphInfo> graphInfos = new List <PlayableGraphInfo>(); PlayableGraphInfo info; // If we requested, we extract automatically the PlayableGraphs from all the components // that are in the current scene. if (m_AutoScanScene) { // This code could be generalized, maybe if we added a IHasPlayableGraph Interface. IList <PlayableDirector> directors = FindObjectsOfType <PlayableDirector>(); if (directors != null) { foreach (var director in directors) { if (director.playableGraph.IsValid()) { info.name = director.name; info.graph = director.playableGraph; graphInfos.Add(info); } } } IList <Animator> animators = FindObjectsOfType <Animator>(); if (animators != null) { foreach (var animator in animators) { if (animator.playableGraph.IsValid()) { info.name = animator.name; info.graph = animator.playableGraph; graphInfos.Add(info); } } } } if (GraphVisualizerClient.GetGraphs() != null) { foreach (var clientGraph in GraphVisualizerClient.GetGraphs()) { if (clientGraph.Key.IsValid()) { info.name = clientGraph.Value; info.graph = clientGraph.Key; graphInfos.Add(info); } } } // Early out if there is no graphs. if (graphInfos.Count == 0) { ShowMessage("No PlayableGraph in the scene"); return; } GUILayout.BeginVertical(); m_CurrentGraphInfo = GetSelectedGraphInToolBar(graphInfos, m_CurrentGraphInfo); GUILayout.EndVertical(); if (!m_CurrentGraphInfo.graph.IsValid()) { ShowMessage("Selected PlayableGraph is invalid"); return; } var graph = new PlayableGraphVisualizer(m_CurrentGraphInfo.graph); graph.Refresh(); if (graph.IsEmpty()) { ShowMessage("Selected PlayableGraph is empty"); return; } if (m_Layout == null) { m_Layout = new ReingoldTilford(); } m_Layout.CalculateLayout(graph); var graphRect = new Rect(0, s_ToolbarHeight, position.width, position.height - s_ToolbarHeight); if (m_Renderer == null) { m_Renderer = new DefaultGraphRenderer(); } m_Renderer.Draw(m_Layout, graphRect, m_GraphSettings); }