public virtual void OnGUI() { Vector2 mp = Event.current.mousePosition; for (int i = 0; i < slots.Count; i++) { var item = slots [i]; if (selection == i) { GUI.color = new Color(0.8f, 0.8f, 0.8f, 1); } else { GUI.color = Color.white; } float x = rectBase.x; float y = rectBase.y; if (rectBase.height > rectBase.width) { y += (slotSize.y + margin) * i; } else { x += slotSize.x * i; } Rect rect = new Rect(x + margin, y, slotSize.x - margin * 2, slotSize.y); if (this is SWSlotBox_Drag) { if (window.IsOperatingWindow()) { GUI.Box(rect, "", item.StyleDrag); } else { GUI.Box(rect, "", item.Style); } } else { if (selection == i) { GUI.Box(rect, "", item.StyleDown); } else { GUI.Box(rect, "", item.Style); } } GUI.color = Color.white; GUI.Label(rect, item.content, SWEditorUI.Style_Get(SWCustomStyle.eTxtLight)); window.Tooltip_Rec(item.eTooltip, rect, -8); if (window.IsOperatingWindow() && Event.current.type == EventType.mouseDown) { if (rect.Contains(mp)) { OnClick(item, mp); } } } GUI.color = Color.white; }
public virtual void OnGUI() { float height = (slotSize.y + margin) * slots.Count; scollViewPos = GUI.BeginScrollView( new Rect(rectBase.x, rectBase.y, slotSize.x + window.al_scrollBarWidth, window.position.height - rectBase.y - window.al_scrollBarWidth), scollViewPos, new Rect(0, 0, slotSize.x - 3, height)); Vector2 mp = Event.current.mousePosition; for (int i = 0; i < slots.Count; i++) { var item = slots [i]; if (selection == i) { GUI.color = new Color(0.8f, 0.8f, 0.8f, 1); } else { GUI.color = Color.white; } float x = 0; float y = 10; if (rectBase.height > rectBase.width) { y += (slotSize.y + margin) * i; } else { x += slotSize.x * i; } Rect rect = new Rect(x + margin, y, slotSize.x - margin * 2, slotSize.y); if (this is SWSlotBox_Drag) { if (window.IsOperatingWindow()) { GUI.Box(rect, "", item.StyleDrag); } else { GUI.Box(rect, "", item.Style); } } else { if (selection == i) { GUI.Box(rect, "", item.StyleDown); } else { GUI.Box(rect, "", item.Style); } } GUI.color = Color.white; GUI.Label(rect, item.content, SWEditorUI.Style_Get(SWCustomStyle.eTxtLight)); window.Tooltip_Rec(item.eTooltip, rect, -8); if (window.IsOperatingWindow() && Event.current.type == EventType.MouseDown) { if (rect.Contains(mp)) { OnClick(item, mp); } } if (rect.Contains(mp)) { RepaintGetDirty(); } } GUI.color = Color.white; GUI.EndScrollView(); }