Skip to content

Commit 33fb976

Browse files
committed
Merge branch 'master' into refactor-serialization-system
# Conflicts: # Assets/com.alelievr.NodeGraphProcessor/package.json # CHANGELOG.md
2 parents 3a07901 + 9cb17d5 commit 33fb976

File tree

6 files changed

+65
-3
lines changed

6 files changed

+65
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/OutputNode")]
8+
public class OutputNode : BaseNode
9+
{
10+
[Input(name = "In")]
11+
public float input;
12+
13+
public override string name => "OutputNode";
14+
15+
public override bool deletable => false;
16+
17+
protected override void Process()
18+
{
19+
// Do stuff
20+
}
21+
}

Assets/Examples/DefaultNodes/Nodes/OutputNode.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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public void Initialize(BaseGraphView owner, BaseNode node)
7070
nodeTarget = node;
7171
this.owner = owner;
7272

73+
if (!node.deletable)
74+
capabilities &= ~Capabilities.Deletable;
75+
7376
owner.computeOrderUpdated += ComputeOrderUpdatedCallback;
7477
node.onMessageAdded += AddMessageView;
7578
node.onMessageRemoved += RemoveMessageView;
@@ -561,7 +564,13 @@ protected void AddInputContainer()
561564

562565
protected virtual void DrawDefaultInspector(bool fromInspector = false)
563566
{
564-
var fields = nodeTarget.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
567+
var fields = nodeTarget.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
568+
// Filter fields from the BaseNode type since we are only interested in user-defined fields
569+
// (better than BindingFlags.DeclaredOnly because we keep any inherited user-defined fields)
570+
.Where(f => f.DeclaringType != typeof(BaseNode))
571+
// Order by MetadataToken to sync the order with the port order (make sure FieldDrawers are next to the correct port)
572+
//TODO: Also consider custom port order
573+
.OrderBy(f => f.MetadataToken);
565574

566575
foreach (var field in fields)
567576
{
@@ -735,6 +744,11 @@ protected VisualElement AddControlField(FieldInfo field, string label = null, bo
735744
controlsContainer.Add(element);
736745
}
737746
}
747+
else
748+
{
749+
// Make sure we create an empty placeholder if FieldFactory can not provide a drawer
750+
if (showInputDrawer) AddEmptyField(field, false);
751+
}
738752

739753
var visibleCondition = field.GetCustomAttribute(typeof(VisibleIf)) as VisibleIf;
740754
if (visibleCondition != null)
@@ -979,6 +993,8 @@ void UpdatePortViewWithPorts(NodePortContainer ports, List< PortView > portViews
979993
SyncPortCounts(ports, new PortView[]{});
980994
else if (ports.Count == 0) // Same when there is no ports
981995
SyncPortCounts(new NodePort[]{}, portViews);
996+
else if (portViews.Count != ports.Count)
997+
SyncPortCounts(ports, portViews);
982998
else
983999
{
9841000
var p = ports.GroupBy(n => n.fieldName);

Assets/com.alelievr.NodeGraphProcessor/Runtime/Elements/BaseNode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public abstract class BaseNode
4747
/// <summary>Show the node controlContainer only when the mouse is over the node</summary>
4848
public virtual bool showControlsOnHover => false;
4949

50+
/// <summary>True if the node can be deleted, false otherwise</summary>
51+
public virtual bool deletable => true;
52+
5053
/// <summary>
5154
/// Container of input ports
5255
/// </summary>

Assets/com.alelievr.NodeGraphProcessor/Runtime/Utils/ExceptionToLog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public static void Call(Action a)
1616
}
1717
catch (Exception e)
1818
{
19-
Debug.LogError(e);
19+
Debug.LogException(e);
2020
}
2121
#endif
2222
}
2323
}
24-
}
24+
}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
### Change
1313
- Serialization backend (use [SerializeReference] instead of JSON)
1414

15+
## [0.10.4]
16+
17+
### Added
18+
- Added deletable bool API on the BaseNode
19+
20+
### Fixed
21+
- Fix missing and inconsistent field drawers on inherited node fields
22+
- Fix inconsistent field drawer positions after unsupported fields
23+
- Fixed port sync code
24+
- Fixed exception to log not handling correctly the stacktraces
25+
1526
## [0.10.1]
1627

1728
### Fixed

0 commit comments

Comments
 (0)