Skip to content

Commit 52c43ce

Browse files
committed
Fixed some issues with the debuggers
1 parent 9cd2335 commit 52c43ce

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

Editor/Windows/FunctionTimeline.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,16 @@ public TimelineContainer(ModularShader shader)
619619
};
620620
_roots.Add(root);
621621
}
622-
622+
623+
if (_roots.Count == 0)
624+
{
625+
Label label = new Label("No roots found");
626+
left.Add(label);
627+
return;
628+
}
623629
var timelineContent = new VisualElement();
624-
if(_roots.Count > 0)
625-
timelineContent.Add(_roots[0]);
630+
631+
timelineContent.Add(_roots[0]);
626632

627633
var timelineScroll = new ScrollView(ScrollViewMode.Vertical);
628634
timelineScroll.AddToClassList("timeline");

Editor/Windows/TemplateGraph.cs

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using UnityEditor;
45
using UnityEngine;
@@ -52,6 +53,7 @@ public void UpdateTab(ModularShader shader)
5253

5354
foreach (var template in shader.BaseModules.Concat(shader.AdditionalModules).SelectMany(x => x.Templates).OrderBy(x => x.Queue))
5455
{
56+
if (template.Template == null) continue;
5557
var module = moduleByTemplate[template];
5658
_pairs.AddRange(_column.AddTemplate(module.Id, template));
5759
}
@@ -78,6 +80,7 @@ private void CreateGUI()
7880

7981
public class TemplateItemElement : VisualElement
8082
{
83+
public float Height => Math.Max(_asset.Keywords.Length, 1) * 15 + 59;
8184
private ModuleTemplate _template;
8285
public TemplateAsset _asset;
8386
public string ModuleId;
@@ -360,22 +363,40 @@ public void AddItemsToElementsHierarchy(List<TemplatePair> pairs)
360363
{
361364
foreach (var item in _items)
362365
{
363-
int i = 0;
364-
float counter = 0;
365-
foreach (TemplatePair pair in pairs.Where(x => x.Left == item))
366-
{
367-
_bezierContainer.Add(new BezierElement(pair));
368-
counter += _child?.GetTotalStackHeight(i) ?? 1;
369-
i++;
370-
}
366+
AddChildrenToHierarchy(item, pairs);
367+
}
368+
}
369+
370+
public void AddChildrenToHierarchy(TemplateItemElement item, List<TemplatePair> pairs)
371+
{
372+
if (!_items.Contains(item)) return;
373+
int i = 0;
374+
float counter = 0;
375+
var relevantPairs = pairs.Where(x => x.Left == item).ToList();
376+
foreach (TemplatePair pair in relevantPairs)
377+
{
378+
_bezierContainer.Add(new BezierElement(pair));
379+
counter += _child?.GetTotalStackHeight(pair.Right) ?? 0;
380+
_child?.AddChildrenToHierarchy(pair.Right, pairs);
381+
i++;
382+
}
371383

372-
if (_child == null)
373-
{
374-
_container.Add(item);
375-
continue;
376-
}
384+
if (_child == null)
385+
{
386+
_container.Add(item);
387+
return;
388+
}
377389

378-
float height = (counter - ((item._asset.Keywords.Length - 1) * 15 + 89)) / 2;
390+
if (relevantPairs.Count == 0)
391+
{
392+
var space = new VisualElement();
393+
space.style.height = item.Height;
394+
_child._container.Add(space);
395+
_container.Add(item);
396+
}
397+
else
398+
{
399+
float height = (counter - (item.Height)) / 2;
379400
var space = new VisualElement();
380401
space.style.height = height;
381402
_container.Add(space);
@@ -384,18 +405,19 @@ public void AddItemsToElementsHierarchy(List<TemplatePair> pairs)
384405
space.style.height = height;
385406
_container.Add(space);
386407
}
387-
388-
_child?.AddItemsToElementsHierarchy(pairs);
408+
389409
}
390410

391-
public float GetTotalStackHeight(int c)
411+
public float GetTotalStackHeight(TemplateItemElement c)
392412
{
393-
if (_child == null) return (_items[c]._asset.Keywords.Length - 1) * 15 + 89;
394-
413+
if (_child == null) return c.Height;
414+
415+
int index = _items.IndexOf(c);
416+
if (_itemsChildren[index].Length == 0) return c.Height;
395417
float counter = 0;
396-
for (int i = 0; i < _itemsChildren[c].Length; i++)
418+
for (int i = 0; i < _itemsChildren[index].Length; i++)
397419
{
398-
counter += _child.GetTotalStackHeight(i);
420+
counter += _child.GetTotalStackHeight(_itemsChildren[index][i]);
399421
}
400422

401423
return counter;

0 commit comments

Comments
 (0)