Skip to content

Commit 237eebc

Browse files
authored
Merge pull request #32 from dannymate/Update-002
2022-11 Update_002
2 parents bac9566 + f5ee575 commit 237eebc

39 files changed

+1376
-456
lines changed

Assets/Examples/ConditionalGraph/ConditionalNode.cs

+54-54
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,65 @@
88

99
namespace NodeGraphProcessor.Examples
1010
{
11-
[System.Serializable]
12-
/// <summary>
13-
/// This is the base class for every node that is executed by the conditional processor, it takes an executed bool as input to
14-
/// </summary>
15-
public abstract class ConditionalNode : BaseNode, IConditionalNode
16-
{
17-
// These booleans will controls wether or not the execution of the folowing nodes will be done or discarded.
18-
[Input(name = "Executed", allowMultiple = true)]
19-
public ConditionalLink executed;
11+
[System.Serializable]
12+
/// <summary>
13+
/// This is the base class for every node that is executed by the conditional processor, it takes an executed bool as input to
14+
/// </summary>
15+
public abstract class ConditionalNode : BaseNode, IConditionalNode
16+
{
17+
// These booleans will controls wether or not the execution of the folowing nodes will be done or discarded.
18+
[MultiEdgeInput(name = "Executed")]
19+
public ConditionalLink executed;
2020

21-
public abstract IEnumerable< ConditionalNode > GetExecutedNodes();
21+
public abstract IEnumerable<ConditionalNode> GetExecutedNodes();
2222

23-
// Assure that the executed field is always at the top of the node port section
24-
public override FieldInfo[] GetNodeFields()
25-
{
26-
var fields = base.GetNodeFields();
27-
Array.Sort(fields, (f1, f2) => f1.Name == nameof(executed) ? -1 : 1);
28-
return fields;
29-
}
30-
}
23+
// Assure that the executed field is always at the top of the node port section
24+
public override FieldInfo[] GetNodeFields()
25+
{
26+
var fields = base.GetNodeFields();
27+
Array.Sort(fields, (f1, f2) => f1.Name == nameof(executed) ? -1 : 1);
28+
return fields;
29+
}
30+
}
3131

32-
[System.Serializable]
33-
/// <summary>
34-
/// This class represent a simple node which takes one event in parameter and pass it to the next node
35-
/// </summary>
36-
public abstract class LinearConditionalNode : ConditionalNode, IConditionalNode
37-
{
38-
[Output(name = "Executes")]
39-
public ConditionalLink executes;
32+
[System.Serializable]
33+
/// <summary>
34+
/// This class represent a simple node which takes one event in parameter and pass it to the next node
35+
/// </summary>
36+
public abstract class LinearConditionalNode : ConditionalNode, IConditionalNode
37+
{
38+
[Output(name = "Executes")]
39+
public ConditionalLink executes;
4040

41-
public override IEnumerable< ConditionalNode > GetExecutedNodes()
42-
{
43-
// Return all the nodes connected to the executes port
44-
return outputPorts.FirstOrDefault(n => n.fieldName == nameof(executes))
45-
.GetEdges().Select(e => e.inputNode as ConditionalNode);
46-
}
47-
}
48-
49-
[System.Serializable]
50-
/// <summary>
51-
/// This class represent a waitable node which invokes another node after a time/frame
52-
/// </summary>
53-
public abstract class WaitableNode : LinearConditionalNode
54-
{
55-
[Output(name = "Execute After")]
56-
public ConditionalLink executeAfter;
41+
public override IEnumerable<ConditionalNode> GetExecutedNodes()
42+
{
43+
// Return all the nodes connected to the executes port
44+
return outputPorts.FirstOrDefault(n => n.fieldName == nameof(executes))
45+
.GetEdges().Select(e => e.inputNode as ConditionalNode);
46+
}
47+
}
5748

58-
protected void ProcessFinished()
59-
{
60-
onProcessFinished.Invoke(this);
61-
}
49+
[System.Serializable]
50+
/// <summary>
51+
/// This class represent a waitable node which invokes another node after a time/frame
52+
/// </summary>
53+
public abstract class WaitableNode : LinearConditionalNode
54+
{
55+
[Output(name = "Execute After")]
56+
public ConditionalLink executeAfter;
6257

63-
[HideInInspector]
64-
public Action<WaitableNode> onProcessFinished;
58+
protected void ProcessFinished()
59+
{
60+
onProcessFinished.Invoke(this);
61+
}
6562

66-
public IEnumerable< ConditionalNode > GetExecuteAfterNodes()
67-
{
68-
return outputPorts.FirstOrDefault(n => n.fieldName == nameof(executeAfter))
69-
.GetEdges().Select(e => e.inputNode as ConditionalNode);
70-
}
71-
}
63+
[HideInInspector]
64+
public Action<WaitableNode> onProcessFinished;
65+
66+
public IEnumerable<ConditionalNode> GetExecuteAfterNodes()
67+
{
68+
return outputPorts.FirstOrDefault(n => n.fieldName == nameof(executeAfter))
69+
.GetEdges().Select(e => e.inputNode as ConditionalNode);
70+
}
71+
}
7272
}

Assets/Examples/DefaultNodes/Editor/ColorNodeView.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
[NodeCustomEditor(typeof(ColorNode))]
1111
public class ColorNodeView : BaseNodeView
1212
{
13-
public override void Enable()
14-
{
15-
AddControlField(nameof(ColorNode.color));
16-
style.width = 200;
17-
}
13+
public override void Enable()
14+
{
15+
AddControlField(new UnityPath(nameof(ColorNode.color)));
16+
style.width = 200;
17+
}
1818
}

Assets/Examples/DefaultNodes/Nodes/CustomPortDataNode.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
[System.Serializable, NodeMenuItem("Custom/PortData")]
88
public class CustomPortData : BaseNode
99
{
10-
[Input(name = "In Values", allowMultiple = true)]
10+
[Input(name = "In Values")]
1111
public IEnumerable<object> inputs = null;
1212

1313
static PortData[] portDatas = new PortData[] {
14-
new PortData{displayName = "0", DisplayType = typeof(float), identifier = "0"},
15-
new PortData{displayName = "1", DisplayType = typeof(int), identifier = "1"},
16-
new PortData{displayName = "2", DisplayType = typeof(GameObject), identifier = "2"},
17-
new PortData{displayName = "3", DisplayType = typeof(Texture2D), identifier = "3"},
14+
new PortData{displayName = "0", acceptMultipleEdges = true, DisplayType = typeof(float), identifier = "0"},
15+
new PortData{displayName = "1", acceptMultipleEdges = true, DisplayType = typeof(int), identifier = "1"},
16+
new PortData{displayName = "2", acceptMultipleEdges = true, DisplayType = typeof(GameObject), identifier = "2"},
17+
new PortData{displayName = "3", acceptMultipleEdges = true, DisplayType = typeof(Texture2D), identifier = "3"},
1818
};
1919

2020
[Output]

Assets/Examples/DefaultNodes/Nodes/DynamicPortGeneration/DynamicNode.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[System.Serializable]
1010
public abstract class DynamicNode<T> : BaseNode
1111
{
12-
[Input("Action Data", true)]
12+
[Input("Action Data")]
1313
public Dictionary<string, List<object>> actionData = new Dictionary<string, List<object>>();
1414

1515
public T data;
@@ -105,8 +105,8 @@ protected IEnumerable<PortData> ActionDataBehaviour(List<SerializableEdge> edges
105105
identifier = field.fieldInfo.Name,
106106
showAsDrawer = field.inputAttribute.showAsDrawer,
107107
vertical = false,
108-
proxiedFieldPath = nameof(data) + '.' + field.fieldInfo.Name,
109-
acceptMultipleEdges = field.inputAttribute.allowMultiple,
108+
proxiedFieldPath = UnityPathFactory.Init().Append(nameof(data)).Assemble(field.fieldInfo.Name),
109+
acceptMultipleEdges = field.inputAttribute.AcceptsMultipleEdges,
110110
};
111111
}
112112

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void UnserializeAndPasteCallback(string operationName, string serializedData)
234234

235235
RegisterCompleteObjectUndo(operationName);
236236

237-
Dictionary<SerializableGuid, BaseNode> copiedNodesMap = new();
237+
Dictionary<PropertyName, BaseNode> copiedNodesMap = new();
238238

239239
var unserializedGroups = data.copiedGroups.Select(g => JsonSerializer.Deserialize<Group>(g)).ToList();
240240

@@ -245,7 +245,7 @@ void UnserializeAndPasteCallback(string operationName, string serializedData)
245245
if (node == null)
246246
continue;
247247

248-
SerializableGuid sourceGUID = node.GUID;
248+
PropertyName sourceGUID = node.GUID;
249249
graph.nodesPerGUID.TryGetValue(sourceGUID, out var sourceNode);
250250
//Call OnNodeCreated on the new fresh copied node
251251
node.createdFromDuplication = true;
@@ -708,7 +708,7 @@ void ReloadView()
708708
graph.Deserialize();
709709

710710
// Get selected nodes
711-
var selectedNodeGUIDs = new List<SerializableGuid>();
711+
var selectedNodeGUIDs = new List<PropertyName>();
712712
foreach (var e in selection)
713713
{
714714
if (e is BaseNodeView v && this.Contains(v))

0 commit comments

Comments
 (0)