Skip to content

Commit 34aecf6

Browse files
committed
Added an assembly definiton file and begin to work on graph processing
1 parent ede1414 commit 34aecf6

10 files changed

Lines changed: 104 additions & 80 deletions

File tree

Assets/Examples/test.asset

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -11,77 +11,8 @@ MonoBehaviour:
1111
m_Script: {fileID: 11500000, guid: 07d56d3b862614a2fbc27b3b7213459b, type: 3}
1212
m_Name: test
1313
m_EditorClassIdentifier:
14-
serializedNodes:
15-
- type: IntNode
16-
jsonDatas: '{"GUID":"ae7c2124-4d00-43b4-b7aa-bb74213fbf54","computeOrder":1,"canProcess":true,"position":{"serializedVersion":"2","x":-436.31439208984377,"y":332.3819274902344,"width":89.0,"height":97.0},"expanded":false,"output":0}'
17-
- type: IntNode
18-
jsonDatas: '{"GUID":"d3c134a5-f9b1-40fe-8eb4-6a6f6a4a39e0","computeOrder":1,"canProcess":true,"position":{"serializedVersion":"2","x":-469.13677978515627,"y":196.05068969726563,"width":89.0,"height":97.0},"expanded":false,"output":0}'
19-
- type: IntNode
20-
jsonDatas: '{"GUID":"240d9400-836b-4fb7-a157-5b7a9ca9318b","computeOrder":1,"canProcess":true,"position":{"serializedVersion":"2","x":-190.6669921875,"y":441.2267761230469,"width":107.0,"height":117.0},"expanded":false,"output":0}'
21-
- type: AddNode
22-
jsonDatas: '{"GUID":"17f48d73-bf80-4f52-ae02-d61b2009878c","computeOrder":4,"canProcess":true,"position":{"serializedVersion":"2","x":196.94322204589845,"y":269.05181884765627,"width":137.0,"height":117.0},"expanded":false,"output":0.0,"test":0}'
23-
- type: IntNode
24-
jsonDatas: '{"GUID":"a1a91bf2-b474-4f89-8235-38a1e71e4c31","computeOrder":1,"canProcess":true,"position":{"serializedVersion":"2","x":-325.8804931640625,"y":228.34747314453126,"width":89.0,"height":97.0},"expanded":false,"output":0}'
25-
- type: AddNode
26-
jsonDatas: '{"GUID":"72345501-f5cc-4083-88d1-9778b11c3c52","computeOrder":5,"canProcess":true,"position":{"serializedVersion":"2","x":182.198974609375,"y":499.8559265136719,"width":137.0,"height":117.0},"expanded":false,"output":0.0,"test":0}'
27-
edges:
28-
- GUID: 1510846b-193f-40a6-8c8f-3c1cc009ca37
29-
owner: {fileID: 11400000}
30-
inputNodeGUID: 17f48d73-bf80-4f52-ae02-d61b2009878c
31-
outputNodeGUID: 240d9400-836b-4fb7-a157-5b7a9ca9318b
32-
inputFieldName: inputs
33-
outputFieldName: output
34-
- GUID: b22c9def-4b20-4bf1-add8-4ba39801b60f
35-
owner: {fileID: 11400000}
36-
inputNodeGUID: 17f48d73-bf80-4f52-ae02-d61b2009878c
37-
outputNodeGUID: ae7c2124-4d00-43b4-b7aa-bb74213fbf54
38-
inputFieldName: inputs
39-
outputFieldName: output
40-
- GUID: dbbd5a7f-0fb7-4b9e-89d8-8b09b9d1fe2e
41-
owner: {fileID: 11400000}
42-
inputNodeGUID: 17f48d73-bf80-4f52-ae02-d61b2009878c
43-
outputNodeGUID: a1a91bf2-b474-4f89-8235-38a1e71e4c31
44-
inputFieldName: inputs
45-
outputFieldName: output
46-
- GUID: 961f9e05-cfa2-4e13-8cac-7f520bbc0c73
47-
owner: {fileID: 11400000}
48-
inputNodeGUID: 72345501-f5cc-4083-88d1-9778b11c3c52
49-
outputNodeGUID: 17f48d73-bf80-4f52-ae02-d61b2009878c
50-
inputFieldName: inputs
51-
outputFieldName: output
52-
commentBlocks:
53-
- title: New Comment Block
54-
color: {r: 0, g: 0, b: 0, a: 0}
55-
position:
56-
serializedVersion: 2
57-
x: NaN
58-
y: NaN
59-
width: NaN
60-
height: NaN
61-
size: {x: 0, y: 0}
62-
innerNodeGUIDs: []
63-
- title: 'test #42'
64-
color: {r: 1, g: 0, b: 0, a: 0.24313726}
65-
position:
66-
serializedVersion: 2
67-
x: -484.13678
68-
y: 142.05069
69-
width: 300.2563
70-
height: 342.33127
71-
size: {x: 340, y: 316}
72-
innerNodeGUIDs:
73-
- d3c134a5-f9b1-40fe-8eb4-6a6f6a4a39e0
74-
- a1a91bf2-b474-4f89-8235-38a1e71e4c31
75-
- ae7c2124-4d00-43b4-b7aa-bb74213fbf54
76-
- title: olol
77-
color: {r: 0.28114074, g: 1, b: 0.051886797, a: 0.32941177}
78-
position:
79-
serializedVersion: 2
80-
x: NaN
81-
y: NaN
82-
width: NaN
83-
height: NaN
84-
size: {x: 274, y: 330}
85-
innerNodeGUIDs: []
86-
position: {x: 323.80103, y: -76.055954, z: 0}
87-
scale: {x: 1, y: 1, z: 1}
14+
serializedNodes: []
15+
edges: []
16+
commentBlocks: []
17+
position: {x: 0, y: 0, z: 0}
18+
scale: {x: 0, y: 0, z: 0}

Assets/NodeGraphProcessor/Editor/BaseGraphWindow.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
using UnityEngine;
55
using UnityEditor;
66
using UnityEngine.Assertions;
7-
using Unity.Properties;
87
using UnityEngine.Experimental.UIElements;
98
using UnityEditor.Experimental.UIElements;
109
using UnityEditor.Experimental.UIElements.GraphView;
1110

12-
using UnityEditor.ShaderGraph;
13-
using UnityEditor.ShaderGraph.Drawing;
14-
1511
namespace GraphProcessor
1612
{
1713
[System.Serializable]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using System.Linq;
5+
using UnityEngine.Jobs;
6+
7+
namespace GraphProcessor
8+
{
9+
public enum GraphProcessState
10+
{
11+
Playing,
12+
Paused,
13+
Stopped,
14+
}
15+
16+
public class BaseGraphProcessor
17+
{
18+
public GraphProcessState state { get; private set; }
19+
20+
BaseGraph graph;
21+
22+
BaseNode[] processOrderedNodes;
23+
24+
public BaseGraphProcessor(BaseGraph graph)
25+
{
26+
this.graph = graph;
27+
28+
UpdateComputeOrder();
29+
30+
}
31+
32+
void UpdateComputeOrder()
33+
{
34+
var tmp = new List< BaseNode >();
35+
36+
tmp.AddRange(graph.nodes);
37+
tmp.Sort((n1, n2) => n1.computeOrder.CompareTo(n2.computeOrder));
38+
39+
processOrderedNodes = tmp.ToArray();
40+
}
41+
42+
public void Process()
43+
{
44+
int count = processOrderedNodes.Length;
45+
46+
for (int i = 0; i < count; i++)
47+
processOrderedNodes[i].OnProcess();
48+
}
49+
50+
public void Pause()
51+
{
52+
53+
}
54+
55+
public void Stop()
56+
{
57+
58+
}
59+
60+
public void NextStep()
61+
{
62+
63+
}
64+
}
65+
}

Assets/NodeGraphProcessor/Editor/Logic/GraphProcessor.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/NodeGraphProcessor/Editor/Views/CommentBlockView.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ void InitializeInnerNodes()
5454
{
5555
foreach (var nodeGUID in commentBlock.innerNodeGUIDs)
5656
{
57+
if (!owner.graph.nodesPerGUID.ContainsKey(nodeGUID))
58+
{
59+
Debug.LogWarning("Node GUID not found: " + nodeGUID);
60+
61+
continue ;
62+
}
5763
var node = owner.graph.nodesPerGUID[nodeGUID];
5864
var nodeView = owner.nodeViewsPerNode[node];
5965

Assets/NodeGraphProcessor/Graph/BaseGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class BaseGraph : ScriptableObject, ISerializationCallbackReceiver
2828
public List< CommentBlock > commentBlocks = new List< CommentBlock >();
2929

3030
[System.NonSerialized]
31-
Dictionary< BaseNode, int > computeOrderDictionary = new Dictionary< BaseNode, int >();
31+
Dictionary< BaseNode, int > computeOrderDictionary = new Dictionary< BaseNode, int >();
3232

3333
//graph visual properties
3434
public Vector3 position;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "NodeGraphProcessor"
3+
}

Assets/NodeGraphProcessor/NodeGraphProcessor.asmdef.meta

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

Assets/NodeGraphProcessor/Utils/JsonSerializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public static BaseNode DeserializeNode(JsonElement e)
4141
{
4242
var baseNodeType = Type.GetType(e.type);
4343

44+
Debug.Log("Jsonelement: " + e.type);
45+
if (e.jsonDatas == null)
46+
return null;
47+
4448
return JsonUtility.FromJson(e.jsonDatas, baseNodeType) as BaseNode;
4549
}
4650
}

Packages/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"dependencies": {
3-
"com.unity.properties": "0.1.18-preview.2"
3+
"com.unity.incrementalcompiler": "0.0.42-preview.1",
4+
"com.unity.entities": "0.0.12-preview.4"
45
},
56
"registry": "https://staging-packages.unity.com"
67
}

0 commit comments

Comments
 (0)