///Variable based nodes public static UnityEditor.GenericMenu AppendVariableNodesMenu(this FlowGraph graph, UnityEditor.GenericMenu menu, string baseCategory, Vector2 pos, Port sourcePort, object dropInstance) { if (!string.IsNullOrEmpty(baseCategory)) { baseCategory += "/"; } var variables = new Dictionary <IBlackboard, List <Variable> >(); if (graph.blackboard != null) { variables[graph.blackboard] = graph.blackboard.variables.Values.ToList(); } foreach (var globalBB in GlobalBlackboard.allGlobals) { variables[globalBB] = globalBB.variables.Values.ToList(); } foreach (var pair in variables) { foreach (var _bbVar in pair.Value) { var bb = pair.Key; var bbVar = _bbVar; var category = baseCategory + "Blackboard/" + (bb == graph.blackboard? "" : bb.name + "/"); var fullName = bb == graph.blackboard? bbVar.name : string.Format("{0}/{1}", bb.name, bbVar.name); if (sourcePort == null || (sourcePort is ValueInput && sourcePort.type.IsAssignableFrom(bbVar.varType))) { var getName = string.Format("{0}Get '{1}'", category, bbVar.name); menu.AddItem(new GUIContent(getName, null, "Get Variable"), false, () => { graph.AddVariableGet(bbVar.varType, fullName, pos, sourcePort, dropInstance); }); } if (sourcePort == null || sourcePort is FlowOutput || (sourcePort is ValueOutput && bbVar.varType.IsAssignableFrom(sourcePort.type))) { var setName = string.Format("{0}Set '{1}'", category, bbVar.name); menu.AddItem(new GUIContent(setName, null, "Set Variable"), false, () => { graph.AddVariableSet(bbVar.varType, fullName, pos, sourcePort, dropInstance); }); } } } return(menu); }