Skip to content

Commit 1c35e8f

Browse files
author
Antoine Lelievre
committed
Added workaround for node view with list bug
1 parent 7f9afeb commit 1c35e8f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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)