@@ -19,6 +19,7 @@ public partial class RenderGraphViewer
19
19
20
20
static partial class Names
21
21
{
22
+ public const string kPanelContainer = "panel-container" ;
22
23
public const string kResourceListFoldout = "panel-resource-list" ;
23
24
public const string kPassListFoldout = "panel-pass-list" ;
24
25
public const string kResourceSearchField = "resource-search-field" ;
@@ -40,18 +41,31 @@ static partial class Classes
40
41
const string k_SelectionColorBeginTag = "<mark=#3169ACAB>" ;
41
42
const string k_SelectionColorEndTag = "</mark>" ;
42
43
44
+ TwoPaneSplitView m_SidePanelSplitView ;
43
45
bool m_ResourceListExpanded = true ;
44
46
bool m_PassListExpanded = true ;
47
+ float m_SidePanelVerticalAspectRatio = 0.5f ;
48
+ float m_SidePanelFixedPaneHeight = 0 ;
45
49
46
50
Dictionary < VisualElement , List < TextElement > > m_ResourceDescendantCache = new ( ) ;
47
51
Dictionary < VisualElement , List < TextElement > > m_PassDescendantCache = new ( ) ;
48
52
49
53
void InitializeSidePanel ( )
50
54
{
55
+ m_SidePanelSplitView = rootVisualElement . Q < TwoPaneSplitView > ( Names . kPanelContainer ) ;
56
+ rootVisualElement . RegisterCallback < GeometryChangedEvent > ( _ =>
57
+ {
58
+ SaveSplitViewFixedPaneHeight ( ) ; // Window resized - save the current pane height
59
+ UpdatePanelHeights ( ) ;
60
+ } ) ;
61
+
51
62
// Callbacks for dynamic height allocation between resource & pass lists
52
63
HeaderFoldout resourceListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kResourceListFoldout ) ;
53
64
resourceListFoldout . RegisterValueChangedCallback ( evt =>
54
65
{
66
+ if ( m_ResourceListExpanded )
67
+ SaveSplitViewFixedPaneHeight ( ) ; // Closing the foldout - save the current pane height
68
+
55
69
m_ResourceListExpanded = resourceListFoldout . value ;
56
70
UpdatePanelHeights ( ) ;
57
71
} ) ;
@@ -61,6 +75,9 @@ void InitializeSidePanel()
61
75
HeaderFoldout passListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kPassListFoldout ) ;
62
76
passListFoldout . RegisterValueChangedCallback ( evt =>
63
77
{
78
+ if ( m_PassListExpanded )
79
+ SaveSplitViewFixedPaneHeight ( ) ; // Closing the foldout - save the current pane height
80
+
64
81
m_PassListExpanded = passListFoldout . value ;
65
82
UpdatePanelHeights ( ) ;
66
83
} ) ;
@@ -247,8 +264,9 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
247
264
}
248
265
249
266
var passItem = new Foldout ( ) ;
250
- passItem . text = string . Join ( ", " , passNames ) ;
251
- passItem . Q < Toggle > ( ) . tooltip = passItem . text ;
267
+ var passesText = string . Join ( ", " , passNames ) ;
268
+ passItem . text = $ "<b>{ passesText } </b>";
269
+ passItem . Q < Toggle > ( ) . tooltip = passesText ;
252
270
passItem . value = false ;
253
271
passItem . userData = m_PassIdToVisiblePassIndex [ visiblePassElement . passId ] ;
254
272
passItem . AddToClassList ( Classes . kPanelListItem ) ;
@@ -270,71 +288,75 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
270
288
}
271
289
else
272
290
{
291
+ CreateTextElement ( passItem , "Pass break reasoning" , Classes . kSubHeaderText ) ;
273
292
var msg = $ "This is a { k_PassTypeNames [ ( int ) firstPassData . type ] } . Only Raster Render Passes can be merged.";
274
293
msg = msg . Replace ( "a Unsafe" , "an Unsafe" ) ;
275
294
CreateTextElement ( passItem , msg ) ;
276
295
}
277
296
278
- CreateTextElement ( passItem , "Render Graph Pass Info" , Classes . kSubHeaderText ) ;
279
- foreach ( int passId in groupedPassIds )
280
- {
281
- var pass = m_CurrentDebugData . passList [ passId ] ;
282
- Debug . Assert ( pass . nrpInfo != null ) ; // This overlay currently assumes NRP compiler
283
- var passFoldout = new Foldout ( ) ;
284
- passFoldout . text = $ "{ pass . name } ({ k_PassTypeNames [ ( int ) pass . type ] } )";
285
- passFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
286
- passFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
287
- passFoldout . Q < Toggle > ( ) . tooltip = passFoldout . text ;
288
-
289
- var foldoutCheckmark = passFoldout . Q ( "unity-checkmark" ) ;
290
- foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
291
-
292
- var lineBreak = new VisualElement ( ) ;
293
- lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
294
- passFoldout . Add ( lineBreak ) ;
295
-
296
- CreateTextElement ( passFoldout ,
297
- $ "Attachment dimensions: { pass . nrpInfo . width } x{ pass . nrpInfo . height } x{ pass . nrpInfo . volumeDepth } ") ;
298
- CreateTextElement ( passFoldout , $ "Has depth attachment: { pass . nrpInfo . hasDepth } ") ;
299
- CreateTextElement ( passFoldout , $ "MSAA samples: { pass . nrpInfo . samples } ") ;
300
- CreateTextElement ( passFoldout , $ "Async compute: { pass . async } ") ;
301
-
302
- passItem . Add ( passFoldout ) ;
303
- }
304
-
305
- CreateTextElement ( passItem , "Attachment Load/Store Actions" , Classes . kSubHeaderText ) ;
306
- if ( nativePassInfo != null && nativePassInfo . attachmentInfos . Count > 0 )
297
+ if ( nativePassInfo != null )
307
298
{
308
- foreach ( var attachmentInfo in nativePassInfo . attachmentInfos )
299
+ CreateTextElement ( passItem , "Render Graph Pass Info" , Classes . kSubHeaderText ) ;
300
+ foreach ( int passId in groupedPassIds )
309
301
{
310
- var attachmentFoldout = new Foldout ( ) ;
311
- attachmentFoldout . text = attachmentInfo . resourceName ;
312
- attachmentFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
313
- attachmentFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
314
- attachmentFoldout . Q < Toggle > ( ) . tooltip = attachmentFoldout . text ;
315
-
316
- var foldoutCheckmark = attachmentFoldout . Q ( "unity-checkmark" ) ;
302
+ var pass = m_CurrentDebugData . passList [ passId ] ;
303
+ Debug . Assert ( pass . nrpInfo != null ) ; // This overlay currently assumes NRP compiler
304
+ var passFoldout = new Foldout ( ) ;
305
+ passFoldout . text = $ "{ pass . name } ({ k_PassTypeNames [ ( int ) pass . type ] } )";
306
+ passFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
307
+ passFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
308
+ passFoldout . Q < Toggle > ( ) . tooltip = passFoldout . text ;
309
+
310
+ var foldoutCheckmark = passFoldout . Q ( "unity-checkmark" ) ;
317
311
foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
318
312
319
313
var lineBreak = new VisualElement ( ) ;
320
314
lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
321
- attachmentFoldout . Add ( lineBreak ) ;
315
+ passFoldout . Add ( lineBreak ) ;
322
316
323
- attachmentFoldout . Add ( new TextElement
324
- {
325
- text = $ "<b>Load action:</b> { attachmentInfo . loadAction } ({ attachmentInfo . loadReason } )"
326
- } ) ;
327
- attachmentFoldout . Add ( new TextElement
328
- {
329
- text = $ "<b>Store action:</b> { attachmentInfo . storeAction } ({ attachmentInfo . storeReason } )"
330
- } ) ;
317
+ CreateTextElement ( passFoldout ,
318
+ $ "Attachment dimensions: { pass . nrpInfo . width } x{ pass . nrpInfo . height } x{ pass . nrpInfo . volumeDepth } ") ;
319
+ CreateTextElement ( passFoldout , $ "Has depth attachment: { pass . nrpInfo . hasDepth } ") ;
320
+ CreateTextElement ( passFoldout , $ "MSAA samples: { pass . nrpInfo . samples } ") ;
321
+ CreateTextElement ( passFoldout , $ "Async compute: { pass . async } ") ;
331
322
332
- passItem . Add ( attachmentFoldout ) ;
323
+ passItem . Add ( passFoldout ) ;
324
+ }
325
+
326
+ CreateTextElement ( passItem , "Attachment Load/Store Actions" , Classes . kSubHeaderText ) ;
327
+ if ( nativePassInfo != null && nativePassInfo . attachmentInfos . Count > 0 )
328
+ {
329
+ foreach ( var attachmentInfo in nativePassInfo . attachmentInfos )
330
+ {
331
+ var attachmentFoldout = new Foldout ( ) ;
332
+ attachmentFoldout . text = attachmentInfo . resourceName ;
333
+ attachmentFoldout . AddToClassList ( Classes . kAttachmentInfoItem ) ;
334
+ attachmentFoldout . AddToClassList ( Classes . kCustomFoldoutArrow ) ;
335
+ attachmentFoldout . Q < Toggle > ( ) . tooltip = attachmentFoldout . text ;
336
+
337
+ var foldoutCheckmark = attachmentFoldout . Q ( "unity-checkmark" ) ;
338
+ foldoutCheckmark . BringToFront ( ) ; // Move foldout checkmark to the right
339
+
340
+ var lineBreak = new VisualElement ( ) ;
341
+ lineBreak . AddToClassList ( Classes . kPanelListLineBreak ) ;
342
+ attachmentFoldout . Add ( lineBreak ) ;
343
+
344
+ attachmentFoldout . Add ( new TextElement
345
+ {
346
+ text = $ "<b>Load action:</b> { attachmentInfo . loadAction } ({ attachmentInfo . loadReason } )"
347
+ } ) ;
348
+ attachmentFoldout . Add ( new TextElement
349
+ {
350
+ text = $ "<b>Store action:</b> { attachmentInfo . storeAction } ({ attachmentInfo . storeReason } )"
351
+ } ) ;
352
+
353
+ passItem . Add ( attachmentFoldout ) ;
354
+ }
355
+ }
356
+ else
357
+ {
358
+ CreateTextElement ( passItem , "No attachments." ) ;
333
359
}
334
- }
335
- else
336
- {
337
- CreateTextElement ( passItem , "No attachments." ) ;
338
360
}
339
361
340
362
content . Add ( passItem ) ;
@@ -343,32 +365,48 @@ void CreateTextElement(VisualElement parent, string text, string className = nul
343
365
}
344
366
}
345
367
346
- void UpdatePanelHeights ( )
368
+ void SaveSplitViewFixedPaneHeight ( )
347
369
{
348
- HeaderFoldout resourceListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kResourceListFoldout ) ;
349
- HeaderFoldout passListFoldout = rootVisualElement . Q < HeaderFoldout > ( Names . kPassListFoldout ) ;
370
+ m_SidePanelFixedPaneHeight = m_SidePanelSplitView . fixedPane ? . resolvedStyle ? . height ?? 0 ;
371
+ }
350
372
373
+ void UpdatePanelHeights ( )
374
+ {
351
375
bool passListExpanded = m_PassListExpanded && ( m_CurrentDebugData != null && m_CurrentDebugData . isNRPCompiler ) ;
352
376
const int kFoldoutHeaderHeightPx = 18 ;
353
- if ( m_ResourceListExpanded && ! passListExpanded )
377
+ const int kWindowExtraMarginPx = 6 ;
378
+
379
+ float panelHeightPx = focusedWindow . position . height - kHeaderContainerHeightPx - kWindowExtraMarginPx ;
380
+ if ( ! m_ResourceListExpanded )
381
+ {
382
+ m_SidePanelSplitView . fixedPaneInitialDimension = kFoldoutHeaderHeightPx ;
383
+ }
384
+ else if ( ! passListExpanded )
354
385
{
355
- resourceListFoldout . style . maxHeight = Length . Percent ( 100 ) ;
356
- passListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
386
+ m_SidePanelSplitView . fixedPaneInitialDimension = panelHeightPx - kFoldoutHeaderHeightPx ;
357
387
}
358
- else if ( ! m_ResourceListExpanded && passListExpanded )
388
+ else
359
389
{
360
- resourceListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
361
- passListFoldout . style . maxHeight = Length . Percent ( 100 ) ;
390
+ // Update aspect ratio in case user has dragged the split view
391
+ if ( m_SidePanelFixedPaneHeight > kFoldoutHeaderHeightPx && m_SidePanelFixedPaneHeight < panelHeightPx - kFoldoutHeaderHeightPx )
392
+ {
393
+ m_SidePanelVerticalAspectRatio = m_SidePanelFixedPaneHeight / panelHeightPx ;
394
+ }
395
+ m_SidePanelSplitView . fixedPaneInitialDimension = panelHeightPx * m_SidePanelVerticalAspectRatio ;
362
396
}
363
- else if ( m_ResourceListExpanded && passListExpanded )
397
+
398
+ // Disable drag line when one of the foldouts is collapsed
399
+ var dragLine = m_SidePanelSplitView . Q ( "unity-dragline" ) ;
400
+ var dragLineAnchor = m_SidePanelSplitView . Q ( "unity-dragline-anchor" ) ;
401
+ if ( ! m_ResourceListExpanded || ! passListExpanded )
364
402
{
365
- resourceListFoldout . style . maxHeight = Length . Percent ( 50 ) ;
366
- passListFoldout . style . maxHeight = Length . Percent ( 50 ) ;
403
+ dragLine . pickingMode = PickingMode . Ignore ;
404
+ dragLineAnchor . pickingMode = PickingMode . Ignore ;
367
405
}
368
406
else
369
407
{
370
- resourceListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
371
- passListFoldout . style . maxHeight = kFoldoutHeaderHeightPx ;
408
+ dragLine . pickingMode = PickingMode . Position ;
409
+ dragLineAnchor . pickingMode = PickingMode . Position ;
372
410
}
373
411
}
374
412
0 commit comments