Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions AssetDependencyGraph/Editor/AssetDependencyGraph.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.UIElements;
#if UNITY_2019_1_OR_NEWER
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
Expand Down Expand Up @@ -87,6 +88,25 @@ public void OnEnable()
{
text = "Clear"
});

var ts = new ToolbarSearchField();
ts.RegisterValueChangedCallback(x => {
if (string.IsNullOrEmpty(x.newValue)) {
m_GraphView.FrameAll();
return;
}

m_GraphView.ClearSelection();
// m_GraphView.graphElements.ForEach(y => { // BROKEN, Case 1268337
m_GraphView.graphElements.ToList().ForEach(y => {
if (y is Node node && y.title.IndexOf(x.newValue, StringComparison.OrdinalIgnoreCase) >= 0) {
m_GraphView.AddToSelection(node);
}
});

m_GraphView.FrameSelection();
});
toolbar.Add(ts);

#if !UNITY_2019_1_OR_NEWER
rootVisualElement = this.GetRootVisualContainer();
Expand Down Expand Up @@ -118,6 +138,7 @@ private void ExploreAsset()
bool hasDependencies = dependencies.Length > 0;

Node mainNode = CreateNode(mainObject, assetPath, true, hasDependencies);
mainNode.userData = 0;

mainNode.SetPosition(new Rect(0, 0, 0, 0));
m_GraphView.AddElement(groupNode);
Expand Down Expand Up @@ -332,6 +353,8 @@ private void ClearGraph()

private void UpdateDependencyNodePlacement(GeometryChangedEvent e)
{
(e.target as VisualElement).UnregisterCallback<GeometryChangedEvent>(UpdateDependencyNodePlacement);

// The current y offset in per depth
var depthYOffset = new Dictionary<int, float>();

Expand Down