|
1 | 1 | using System.Collections.Generic;
|
2 | 2 | using UnityEditor;
|
| 3 | +using UnityEditor.UIElements; |
3 | 4 | #if UNITY_2019_1_OR_NEWER
|
4 | 5 | using UnityEditor.Experimental.GraphView;
|
5 | 6 | using UnityEngine.UIElements;
|
@@ -87,6 +88,25 @@ public void OnEnable()
|
87 | 88 | {
|
88 | 89 | text = "Clear"
|
89 | 90 | });
|
| 91 | + |
| 92 | + var ts = new ToolbarSearchField(); |
| 93 | + ts.RegisterValueChangedCallback(x => { |
| 94 | + if (string.IsNullOrEmpty(x.newValue)) { |
| 95 | + m_GraphView.FrameAll(); |
| 96 | + return; |
| 97 | + } |
| 98 | + |
| 99 | + m_GraphView.ClearSelection(); |
| 100 | + // m_GraphView.graphElements.ForEach(y => { // BROKEN, Case 1268337 |
| 101 | + m_GraphView.graphElements.ToList().ForEach(y => { |
| 102 | + if (y is Node node && y.title.IndexOf(x.newValue, StringComparison.OrdinalIgnoreCase) >= 0) { |
| 103 | + m_GraphView.AddToSelection(node); |
| 104 | + } |
| 105 | + }); |
| 106 | + |
| 107 | + m_GraphView.FrameSelection(); |
| 108 | + }); |
| 109 | + toolbar.Add(ts); |
90 | 110 |
|
91 | 111 | #if !UNITY_2019_1_OR_NEWER
|
92 | 112 | rootVisualElement = this.GetRootVisualContainer();
|
@@ -118,6 +138,7 @@ private void ExploreAsset()
|
118 | 138 | bool hasDependencies = dependencies.Length > 0;
|
119 | 139 |
|
120 | 140 | Node mainNode = CreateNode(mainObject, assetPath, true, hasDependencies);
|
| 141 | + mainNode.userData = 0; |
121 | 142 |
|
122 | 143 | mainNode.SetPosition(new Rect(0, 0, 0, 0));
|
123 | 144 | m_GraphView.AddElement(groupNode);
|
@@ -332,6 +353,8 @@ private void ClearGraph()
|
332 | 353 |
|
333 | 354 | private void UpdateDependencyNodePlacement(GeometryChangedEvent e)
|
334 | 355 | {
|
| 356 | + (e.target as VisualElement).UnregisterCallback<GeometryChangedEvent>(UpdateDependencyNodePlacement); |
| 357 | + |
335 | 358 | // The current y offset in per depth
|
336 | 359 | var depthYOffset = new Dictionary<int, float>();
|
337 | 360 |
|
|
0 commit comments