1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| private Rect dragWinPos = new Rect(400, 400, 200, 100); private bool isModel = false;
private void OnGUI() { GUI.Window(1, new Rect(100, 100, 200, 150), DrawWindow, "测试窗口"); GUI.Window(2, new Rect(100, 350, 200, 150), DrawWindow, "测试窗口");
if (isModel) { GUI.ModalWindow(3, new Rect(300, 100, 200, 150), DrawWindow, "模态窗口"); }
dragWinPos = GUI.Window(4, dragWinPos, DrawWindow, "可拖动窗口"); }
private void DrawWindow(int id) { switch (id) { case 1: if (GUI.Button(new Rect(0, 30, 30, 20), "1")) { isModel = true; break; } break; case 2: GUI.Button(new Rect(0, 30, 30, 20), "2"); break; case 3: if (GUI.Button(new Rect(0, 30, 30, 20), "3")) { isModel = false; break; } break; case 4: GUI.DragWindow(new Rect(0, 0, 1000, 20)); break; } }
|