Skip to content

Commit 35a0514

Browse files
committed
Added workaround for node view with list bug
1 parent eb3d182 commit 35a0514

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using GraphProcessor;
5+
using System.Linq;
6+
7+
[System.Serializable, NodeMenuItem("Custom/List")]
8+
public class ListNode : BaseNode
9+
{
10+
[Output(name = "Out")]
11+
public Vector4 output;
12+
13+
[Input(name = "In"), SerializeField]
14+
public Vector4 input;
15+
16+
public List<GameObject> objs = new List<GameObject>();
17+
18+
public override string name => "List";
19+
20+
protected override void Process()
21+
{
22+
output = input;
23+
}
24+
}

Assets/Examples/DefaultNodes/Nodes/ListNode.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/com.alelievr.NodeGraphProcessor/Editor/Views/BaseNodeView.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,6 @@ void UpdateTitle()
234234
title = (nodeTarget.GetCustomName() == null) ? nodeTarget.GetType().Name : nodeTarget.GetCustomName();
235235
}
236236

237-
public void UpdateNodeSerializedPropertyBindings()
238-
{
239-
240-
}
241-
242237
void InitializeSettings()
243238
{
244239
// Initialize settings button:
@@ -270,6 +265,21 @@ void OnGeometryChanged(GeometryChangedEvent evt)
270265
settingsContainer.style.left = settingsButtonLayout.xMin - layout.width + 20f;
271266
}
272267
}
268+
269+
// Workaround for bug in GraphView that makes the node selection border way too big
270+
VisualElement selectionBorder, nodeBorder;
271+
internal void EnableSyncSelectionBorderHeight()
272+
{
273+
if (selectionBorder == null || nodeBorder == null)
274+
{
275+
selectionBorder = this.Q("selection-border");
276+
nodeBorder = this.Q("node-border");
277+
278+
schedule.Execute(() => {
279+
selectionBorder.style.height = nodeBorder.localBound.height;
280+
}).Every(17);
281+
}
282+
}
273283

274284
void CreateSettingButton()
275285
{
@@ -681,7 +691,6 @@ protected virtual void DrawDefaultInspector(bool fromInspector = false)
681691
continue;
682692
}
683693

684-
685694
//skip if the field is an input/output and not marked as SerializedField
686695
bool hasInputAttribute = field.GetCustomAttribute(typeof(InputAttribute)) != null;
687696
bool hasInputOrOutputAttribute = hasInputAttribute || field.GetCustomAttribute(typeof(OutputAttribute)) != null;
@@ -852,6 +861,9 @@ protected VisualElement AddControlField(FieldInfo field, string label = null, bo
852861
element.AddToClassList("DrawerField_2020_3");
853862
#endif
854863

864+
if (typeof(IList).IsAssignableFrom(field.FieldType))
865+
EnableSyncSelectionBorderHeight();
866+
855867
element.RegisterValueChangeCallback(e => {
856868
UpdateFieldVisibility(field.Name, field.GetValue(nodeTarget));
857869
valueChangedCallback?.Invoke();

0 commit comments

Comments
 (0)