public List <Node> GenerateUnit(List <string> lines, ref Vector2 point, ref Vector2 startPoint, string unitName = null) { var generatedNodes = new List <Node>(); int index = -1; while (index < lines.Count - 1) { var nodes = GenerateNode(lines, point, ref index, Root, false); if (nodes == null) { break; } if (nodes.All(x => x is FunctionNode)) { var func = nodes.Where(x => x is FunctionNode).Cast <FunctionNode>(); if (unitName != null) { foreach (var functionNode in func) { functionNode.UpdateUnitName(unitName); } } Functions.AddRange(func.ToDictionary(x => x.Name, x => x)); } else if (nodes.SingleOrDefault(x => x is VarNode) != null) { if (Vars == null) { Vars = nodes.First() as VarNode; Vars.transform.position = startPoint; startPoint.y += 300; } else { Vars.AddVars((nodes.First() as VarNode).Vars); } } else if (nodes.SingleOrDefault(x => x is ConstNode) != null) { nodes.SingleOrDefault().transform.position = startPoint; startPoint.y += 300; } else if (nodes.Any()) { generatedNodes.AddRange(nodes); point = new Vector2(point.x, nodes.Last().GetBottom().y) + new Vector2(0, -g_Margin); } } return(generatedNodes); }