void Tips() { this.StartIM(); for (int i = 0; i < rects.Count; i++) { var rt = rects[i]; if (rt.Contains(UI.mousePosRef)) { //show tips IMUI.fontStyle.normal.textColor = tipsTxtColor; var str = tips[i]; var size = IMUI.CalSize(str); size += fontBorder; var os = offset + osFactor * size; GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d); GLUI.BeginOrder(2); var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d); bg.Draw(tipsBgColor, true); if (Events.MouseDown1to3) { Select(i); return; } } } }
public void Input() { ic.order = drawOrder; this.BeginOrtho(); var startPos = this.AbsRefPos(); rects = new List <Rect>(); for (int y = 0; y < gridCount.y; y++) { for (int x = 0; x < gridCount.x; x++) { rects.Add(new Rect(startPos + gridOsFactor * new Vector2(x, y) * (gridOs + gridSize), gridSize, pivot)); } } var i = 0; bool clicked = false; foreach (var rt in rects) { if (visible.NotEmpty() && !visible[i]) { i++; continue; } GLUI.fontColor = fontColor; GLUI.BeginOrder(0); if (!clickable[i]) { DrawButton(rt, 2); } else { if (rt.Contains(UI.mousePosRef) && clickable[i]) { OnOver(i); if (Events.Mouse1to3) { DrawButton(rt, 2); if (Events.MouseDown1to3 && !clicked) { OnClick(i); clicked = true; } } else { DrawButton(rt, 1); if (drawTips) { // tips var str = names[i]; var size = IMUI.CalSize(str); size += fontBorder; var os = offset + osFactor * size; GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d); GLUI.BeginOrder(3); var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d); bg.Draw(Color.white, true); } } } else { DrawButton(rt, 0); } if (drawName) { GLUI.DrawString(names[i], (rt.pos + nameOffset), Vectors.half2d); } GLUI.BeginOrder(1); if (textures.NotEmpty() && textures[i] != null) { GLUI.DrawTex(textures[i], rt.ToPointsCWLT(-1)); } GLUI.SetLineMat(); GLUI.BeginOrder(0); } // 待做优化 tex和line分开两个loop GLUI.BeginOrder(2); if (drawBorder) { rt.Draw(drawBorderClr, false); } i++; } }