public static Item AppendItems(Vector2 mousePos, Graph graph, IOutlet <object> clickedOutlet, int priority = 4) /// Item set appeared on node or outlet click { Item addItems = null; if (clickedOutlet != null) { Type genericLinkType = Generator.GetGenericType(clickedOutlet); if (genericLinkType == null) { throw new Exception("Could not find category " + clickedOutlet.GetType().ToString()); } Item createItems = CreateItems(mousePos, graph); addItems = createItems.Find(GetCategoryByType(genericLinkType)); } if (addItems != null && addItems.subItems != null) { Item initial = addItems.Find("Initial"); if (initial != null) { initial.disabled = true; } //adding link to all create actions foreach (Item item in addItems.All(true)) { if (item.onClick != null) { Action baseOnClick = item.onClick; item.onClick = () => { baseOnClick(); Generator createdGen = graph.generators[graph.generators.Length - 1]; //the last on is the one that's just created. Hacky Vector2 pos = clickedOutlet.Gen.guiPosition + new Vector2(200, 0); GeneratorDraw.FindPlace(ref pos, new Vector2(100, 200), GraphWindow.current.graph); createdGen.guiPosition = pos; graph.AutoLink(createdGen, clickedOutlet); GraphWindow.RefreshMapMagic(createdGen); }; } } } else { addItems = new Item("Add"); addItems.onDraw = RightClick.DrawItem; addItems.disabled = true; } addItems.name = "Add (Append)"; addItems.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Create"); addItems.color = Color.gray; addItems.priority = priority; return(addItems); }