11using System ;
22using System . Collections . Generic ;
3- using System . Linq ;
43using GBG . PlayableGraphMonitor . Editor . Node ;
54using UnityEditor ;
6- using UnityEditor . Playables ;
75using UnityEditor . UIElements ;
86using UnityEngine ;
97using UnityEngine . Playables ;
108using UnityEngine . UIElements ;
11- using UNode = UnityEditor . Experimental . GraphView . Node ;
9+
10+ // using UNode = UnityEditor.Experimental.GraphView.Node;
1211
1312
1413namespace GBG . PlayableGraphMonitor . Editor
@@ -59,9 +58,7 @@ public partial class PlayableGraphMonitorWindow
5958 private ToolbarButton _manualUpdateViewButton ;
6059
6160 // Node search
62- private ToolbarPopupSearchField _searchField ;
6361 private ToolbarButton _searchNodeButton ;
64- private ToolbarMenu _searchNodeMenu ;
6562
6663 // Common data
6764 private static Color NotableTextColor => Color . red ;
@@ -78,8 +75,22 @@ private void CreateToolbar()
7875
7976 // Playable graph popup
8077 _graphPopupField = new SearchablePopupField < PlayableGraph > ( _graphs , 0 ,
81- GraphPopupFieldFormatter , GraphPopupFieldFormatter ) ;
78+ GraphPopupFieldFormatter , GraphPopupFieldFormatter )
79+ {
80+ style =
81+ {
82+ marginTop = 0 ,
83+ marginBottom = 0 ,
84+ }
85+ } ;
8286 _graphPopupField . RegisterValueChangedCallback ( OnSelectedPlayableGraphChanged ) ;
87+ VisualElement playableGraphPopupInput = _graphPopupField . Q < VisualElement > ( className : SearchablePopupField < PlayableGraph > . inputUssClassName ) ;
88+ playableGraphPopupInput . style . borderTopLeftRadius = 0 ;
89+ playableGraphPopupInput . style . borderTopRightRadius = 0 ;
90+ playableGraphPopupInput . style . borderBottomLeftRadius = 0 ;
91+ playableGraphPopupInput . style . borderBottomRightRadius = 0 ;
92+ playableGraphPopupInput . style . borderTopWidth = 0 ;
93+ playableGraphPopupInput . style . borderBottomWidth = 0 ;
8394 _graphPopupField . Q < TextElement > ( className : "unity-text-element" ) . style . color = NormalTextColor ;
8495 _toolbar . Add ( _graphPopupField ) ;
8596 _toolbar . Add ( new ToolbarSpacer ( ) ) ;
@@ -147,8 +158,20 @@ private void CreateToolbar()
147158 _refreshRateField = new EnumField ( _refreshRate )
148159 {
149160 tooltip = "Max refresh rate." ,
161+ style =
162+ {
163+ marginTop = 0 ,
164+ marginBottom = 0 ,
165+ }
150166 } ;
151167 _refreshRateField . RegisterValueChangedCallback ( OnRefreshRateChanged ) ;
168+ VisualElement refreshRateInput = _refreshRateField . Q < VisualElement > ( className : EnumField . inputUssClassName ) ;
169+ refreshRateInput . style . borderTopLeftRadius = 0 ;
170+ refreshRateInput . style . borderTopRightRadius = 0 ;
171+ refreshRateInput . style . borderBottomLeftRadius = 0 ;
172+ refreshRateInput . style . borderBottomRightRadius = 0 ;
173+ refreshRateInput . style . borderTopWidth = 0 ;
174+ refreshRateInput . style . borderBottomWidth = 0 ;
152175 _refreshRateLabel = _refreshRateField . Q < TextElement > ( className : "unity-text-element" ) ;
153176 _refreshRateLabel . style . color = _refreshRate != RefreshRate . Manual ? NormalTextColor : NotableTextColor ;
154177 _toolbar . Add ( _refreshRateField ) ;
@@ -171,7 +194,11 @@ private void CreateToolbar()
171194 var frameAllButton = new ToolbarButton ( OnFrameAllButtonClicked )
172195 {
173196 text = "Frame All" ,
174- style = { flexShrink = 0 } ,
197+ style =
198+ {
199+ flexShrink = 0 ,
200+ unityTextAlign = TextAnchor . MiddleCenter ,
201+ } ,
175202 } ;
176203 frameAllButton . Q < TextElement > ( className : "unity-text-element" ) . style . color = NormalTextColor ;
177204 _toolbar . Add ( frameAllButton ) ;
@@ -180,12 +207,14 @@ private void CreateToolbar()
180207 _toolbar . Add ( new ToolbarSpacer ( ) ) ;
181208 _searchNodeButton = new ToolbarButton ( ShowSearchNodeWindow )
182209 {
183- text = "Search Nodes"
210+ text = "Search Nodes" ,
211+ style =
212+ {
213+ flexShrink = 0 ,
214+ unityTextAlign = TextAnchor . MiddleCenter ,
215+ } ,
184216 } ;
185217 _toolbar . Add ( _searchNodeButton ) ;
186- _searchNodeMenu = new ToolbarMenu ( ) ;
187- _searchNodeMenu . RegisterCallback < PointerDownEvent > ( OnClickSearchNodeMenu ) ;
188- _toolbar . Add ( _searchNodeMenu ) ;
189218 }
190219
191220 private string GraphPopupFieldFormatter ( PlayableGraph graph )
@@ -368,22 +397,15 @@ private string FormatGraphViewNodeSearchableName(GraphViewNode node)
368397 return node . ToString ( ) ;
369398 }
370399
371- private void OnClickSearchNodeMenu ( PointerDownEvent evt )
372- {
373- _searchNodeMenu . menu . MenuItems ( ) . Clear ( ) ;
374- PopulateRootNodeDropdownMenu ( _searchNodeMenu . menu ) ;
375- PopulateOutputNodeDropdownMenu ( _searchNodeMenu . menu ) ;
376- }
377-
378- private void PopulateRootNodeDropdownMenu ( DropdownMenu menu )
400+ /*
401+ private void PopulateRootNodeDropdownMenu(GenericMenu menu)
379402 {
380403 const string ROOT_NODES = "Root Playable Nodes";
381404
382405 var playableGraph = _graphPopupField.value;
383406 if (!playableGraph.IsValid())
384407 {
385- menu . AppendAction ( "No Root Playable Node" , null ,
386- DropdownMenuAction . Status . Disabled ) ;
408+ menu.AddDisabledItem(new GUIContent("No Root Playable Node"));
387409 return;
388410 }
389411
@@ -414,7 +436,7 @@ private void PopulateRootNodeDropdownMenu(DropdownMenu menu)
414436 ? $"#{i} [{playableNode.ExtraLabel}] {playableNode.Playable.GetPlayableType().Name}"
415437 : $"#{i} {playableNode.Playable.GetPlayableType().Name}";
416438
417- menu . AppendAction ( $ "{ ROOT_NODES } /{ nodeName } ", _ =>
439+ menu.AddItem(new GUIContent( $"{ROOT_NODES}/{nodeName}"), false, () =>
418440 {
419441 _graphView.ClearSelection();
420442 _graphView.AddToSelection(playableNode);
@@ -424,20 +446,18 @@ private void PopulateRootNodeDropdownMenu(DropdownMenu menu)
424446
425447 if (rootPlayableCount == 0)
426448 {
427- menu . AppendAction ( "No Root Playable Node" , null ,
428- DropdownMenuAction . Status . Disabled ) ;
449+ menu.AddDisabledItem(new GUIContent("No Root Playable Node"));
429450 }
430451 }
431452
432- private void PopulateOutputNodeDropdownMenu ( DropdownMenu menu )
453+ private void PopulateOutputNodeDropdownMenu(GenericMenu menu)
433454 {
434455 const string OUTPUT_NODES = "PlayableOutput Nodes";
435456
436457 var playableGraph = _graphPopupField.value;
437458 if (!playableGraph.IsValid())
438459 {
439- menu . AppendAction ( "No PlayableOutput Node" , null ,
440- DropdownMenuAction . Status . Disabled ) ;
460+ menu.AddDisabledItem(new GUIContent("No PlayableOutput Node"));
441461 return;
442462 }
443463
@@ -466,7 +486,7 @@ private void PopulateOutputNodeDropdownMenu(DropdownMenu menu)
466486
467487 var nodeName = $"#{i} [{outputNode.PlayableOutput.GetEditorName()}]" +
468488 $" {outputNode.PlayableOutput.GetPlayableOutputType().Name}";
469- menu . AppendAction ( $ "{ OUTPUT_NODES } /{ nodeName } ", _ =>
489+ menu.AddItem(new GUIContent( $"{OUTPUT_NODES}/{nodeName}"), false, () =>
470490 {
471491 _graphView.ClearSelection();
472492 _graphView.AddToSelection(outputNode);
@@ -476,10 +496,10 @@ private void PopulateOutputNodeDropdownMenu(DropdownMenu menu)
476496
477497 if (outputCount == 0)
478498 {
479- menu . AppendAction ( "No PlayableOutput Node" , null ,
480- DropdownMenuAction . Status . Disabled ) ;
499+ menu.AddDisabledItem(new GUIContent("No PlayableOutput Node"));
481500 }
482501 }
502+ */
483503
484504 #endregion
485505 }
0 commit comments