Skip to content

Commit 03452ed

Browse files
committed
Added deletable bool API on the BaseNode
1 parent d765749 commit 03452ed

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
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: 3 additions & 0 deletions
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;

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>

0 commit comments

Comments
 (0)