Skip to content

Commit ad4e4bb

Browse files
committed
fix(tools): add extra check on tech tree window to avoid error on null nodes
1 parent 6e1ab9e commit ad4e4bb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎Assets/Editor/TechnologyTree/TechnologyTreeWindow.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void CreateGraph(object objRoot)
8686
List<TechnologyNodeData> newNodes = new List<TechnologyNodeData>();
8787
foreach (TechnologyNodeData n in currentNodes)
8888
{
89+
if (n == null) continue;
8990
editorNode = new TechnologyTreeEditorNode(
9091
n,
9192
new Vector2(paddingX + x * nodeXSpacing, paddingY + y * nodeYSpacing),
@@ -102,8 +103,14 @@ public void CreateGraph(object objRoot)
102103
nodesMapping[n.code] = editorNode;
103104
_nodes.Add(editorNode);
104105

105-
foreach (TechnologyNodeData child in n.children)
106+
List<TechnologyNodeData> children = new List<TechnologyNodeData>(n.children);
107+
foreach (TechnologyNodeData child in children)
106108
{
109+
if (child == null)
110+
{
111+
n.children.Remove(child);
112+
continue;
113+
}
107114
edges.Add((n, child));
108115
newNodes.Add(child);
109116
}

‎Assets/Scripts/TechnologyTree/TechnologyNodeVisualizer.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public float Y
5151

5252
public void Draw(Transform parent, float xOffset)
5353
{
54-
if (_node.code == TechnologyNodeData.ROOT_NODE_CODE)
55-
return;
56-
5754
GameObject g = GameObject.Instantiate(_UI_PREFAB, parent);
5855
RectTransform rt = g.GetComponent<RectTransform>();
5956
rt.anchoredPosition =

0 commit comments

Comments
 (0)