public GuiObject BuildBinWindow(ItemBin bin) { GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Bin"); Func <ItemCount, int, int, int> DrawItemBox = delegate(ItemCount i, int y, int w) { GUI.Box(new Rect(5, y, w - 110, 40), i.item.GetName() + " -- " + i.amount); GUI.Label(new Rect(10, y + 20, w - 110, 20), i.item.GetDescription()); if (GUI.Button(new Rect(w - 100, y, 80, 18), "Take")) { man.GetComponent <Inventory>().AddToInventory(bin.TakeItem(i.item)); } if (i.amount > 1 && GUI.Button(new Rect(w - 100, y + 22, 80, 18), "Take All")) { man.GetComponent <Inventory>().AddToInventory(bin.TakeItem(i.item, i.amount)); } return(45); }; Vector2 pos = Vector2.zero; window.AddChild(new GuiObject(new Rect(5, 25, 290, 470), (g) => { int numItems = bin.GetNumItems(); pos = GUI.BeginScrollView(g.rect, pos, new Rect(0, 0, g.rect.width - 20, numItems * 45)); int ypos = 5; foreach (var a in bin.inventoryList) { ypos += DrawItemBox(a, ypos, (int)g.rect.width); } GUI.EndScrollView(); }, "ItemList", "")); return(window); }
public GuiObject BuildBinWindow(ItemBin bin) { GuiObject window = new GuiObject(new Rect(0, 0, 300, 500), "LeftPane", "Bin"); Func<ItemCount, int, int, int> DrawItemBox = delegate(ItemCount i, int y, int w) { GUI.Box(new Rect(5, y, w - 110, 40), i.item.GetName() + " -- " + i.amount); GUI.Label(new Rect(10, y + 20, w - 110, 20), i.item.GetDescription()); if (GUI.Button(new Rect(w - 100, y, 80, 18), "Take")) { man.GetComponent<Inventory>().AddToInventory(bin.TakeItem(i.item)); } if (i.amount > 1 && GUI.Button(new Rect(w - 100, y + 22, 80, 18), "Take All")) { man.GetComponent<Inventory>().AddToInventory(bin.TakeItem(i.item, i.amount)); } return 45; }; Vector2 pos = Vector2.zero; window.AddChild(new GuiObject(new Rect(5, 25, 290, 470), (g) => { int numItems = bin.GetNumItems(); pos = GUI.BeginScrollView(g.rect, pos, new Rect(0, 0, g.rect.width - 20, numItems * 45)); int ypos = 5; foreach (var a in bin.inventoryList) { ypos += DrawItemBox(a, ypos, (int)g.rect.width); } GUI.EndScrollView(); }, "ItemList", "")); return window; }