private void drawInventoryElement(int index, Rect eleRect, Org.Dragonet.Cloudland.Net.Protocol.GUIElement element) { int itemsPerLine = (int)((eleRect.width - 24) / 40.0f); int line = 0; GUI.Box(eleRect, ""); for (uint i = 0; i < element.Value.Entries.Count; i++) { int id = element.Value.Entries[i].MetaValue.Entries[0].Int32Value; int count = element.Value.Entries[i].MetaValue.Entries[1].Int32Value; Rect slot = new Rect(eleRect.x + 12 + (i % itemsPerLine) * 40, eleRect.y + line * 40f + 12, 32, 32); Rect slotCount = new Rect(eleRect.x + 12 + (i % itemsPerLine) * 40 + 16, eleRect.y + line * 40f + 28, 24, 8); bool clicked = false; clicked |= GUI.Button(slot, Inventory.getItemTexture(id), blankStyle); clicked |= GUI.Button(slotCount, count.ToString(), blankStyle); if (clicked) { buttonPressed(index, (int)i, Event.current.button); } if ((i + 1) % itemsPerLine == 0) { line++; } } }
void func(int unityWindowId) { for (int i = 0; i < elements.Count; i++) { Org.Dragonet.Cloudland.Net.Protocol.GUIElement ele = elements[i]; Rect eleRect = new Rect(ele.X, ele.Y, ele.Width, ele.Height); bool pressed = false; switch (ele.Type) { case GUIElementType.Text: GUI.Label(eleRect, ele.Value.Entries[0].StringValue); break; case GUIElementType.Button: pressed = GUI.Button(eleRect, ele.Value.Entries[0].StringValue); if (pressed) { buttonPressed(i, 0, 0); } break; case GUIElementType.LineInput: ele.Value.Entries[0].StringValue = GUI.TextField(eleRect, ele.Value.Entries[0].StringValue); break; case GUIElementType.AreaInput: ele.Value.Entries[0].StringValue = GUI.TextArea(eleRect, ele.Value.Entries[0].StringValue); break; case GUIElementType.Inventory: drawInventoryElement(i, eleRect, ele); break; default: Debug.Log("Can't recognise GUI element type"); break; } } if (GUI.Button(new Rect(rect.width - 16, 4, 16, 16), "X")) { close(true); } }
public void updateElement(int index, Org.Dragonet.Cloudland.Net.Protocol.GUIElement element) { elements[index] = element; }