public override void Update() { scrollPos = QEditorLayout.ScrollView(() => { for (i = 0; i < list.Count; i++) { QEditorLayout.Horizontal(x => { if (doubleClickIndex != i) { EditorGUILayout.LabelField(list[i], itemWidth, itemHeight); ContextMenuEvent(x, true); SelectEvent(x); if (isEditor) { EditorEvent(x); } if (isDrag) { DragEvent(x); } } else { list[doubleClickIndex] = EditorGUILayout.TextArea(list[doubleClickIndex], itemWidth, itemHeight); } }, i == index ? select : about); } ContextMenuEvent(EditorGUILayout.GetControlRect(), false); }, scrollPos, scrollWidth, sorollHeight); }
private void OnGUI() { QEditorLayout.Horizontal(x => { for (int i = 0; i < 2; i++) { l[i].Update(); } }); }
public static string TimerEditor(string label, string time) { if (timeData.SetHMS(time)) { timeData.Init(); } QEditorLayout.Horizontal(x => { EditorGUILayout.PrefixLabel(label); QEditorLayout.Horizontal(x2 => { startWidth = x2.width; x2.width = 15; #region 时 if (QEditorEvent.IsScrollWhell(x2)) { timeData.Hour += TimerEditorDalta(); } #endregion #region 分 x2.x += 20; if (QEditorEvent.IsScrollWhell(x2)) { timeData.Minute += TimerEditorDalta(); } #endregion #region 秒 x2.x += 20; if (QEditorEvent.IsScrollWhell(x2)) { timeData.Seconds += TimerEditorDalta(); } #endregion #region 毫秒 x2.x += 18; x2.width = startWidth - 58; if (QEditorEvent.IsScrollWhell(x2)) { timeData.Milliseconds += TimerEditorDalta(); } #endregion time = EditorGUILayout.TextField(timeData.ToString()); }); }); if (timeData.SetHMS(time)) { time = timeData.ToString(); } return(time); }
public static string PathField(string label, string path, int width = 0) { QEditorLayout.Horizontal(x => { EditorGUILayout.LabelField(label); if (width > 0) { pathRect = new Rect(x.x + width, x.y, x.width - width, x.height); } else { pathRect = EditorGUILayout.GetControlRect(); } path = EditorGUI.TextField(pathRect, path); if (QEditorEvent.IsDragPerform(pathRect)) { path = DragAndDrop.paths[0]; } }); return(path); }
/// <summary> /// 使用该函数前必须使用 BeginWindows 和 EndWindows 包裹才能显示 /// </summary> /// <param name="rect"></param> /// <param name="label"></param> /// <param name="fun"></param> /// <param name="isDrag"></param> /// <returns></returns> public static StandardButton MessageBox(Rect rect, string label, Action <Rect> fun, StandardButton button = StandardButton.OK | StandardButton.No, bool isDrag = true) { rect = GUILayout.Window(0, rect, id => { GUI.enabled = true; fun.Invoke(rect); GUILayout.FlexibleSpace(); if (button == StandardButton.OK) { if (GUILayout.Button("Ok")) { b = StandardButton.OK; } } else if (button == StandardButton.No) { if (GUILayout.Button("No")) { b = StandardButton.No; } } else if (button == StandardButton.Cancel) { if (GUILayout.Button("Cancel")) { b = StandardButton.Cancel; } } else if (button == (StandardButton.OK | StandardButton.No)) { QEditorLayout.Horizontal(e => { if (GUILayout.Button("Ok")) { b = StandardButton.OK; } if (GUILayout.Button("No")) { b = StandardButton.No; } }); } else if (button == (StandardButton.OK | StandardButton.Cancel)) { QEditorLayout.Horizontal(e => { if (GUILayout.Button("Ok")) { b = StandardButton.OK; } if (GUILayout.Button("Cancel")) { b = StandardButton.Cancel; } }); } else if (button == (StandardButton.OK | StandardButton.No | StandardButton.Cancel)) { QEditorLayout.Horizontal(e => { if (GUILayout.Button("Ok")) { b = StandardButton.OK; } if (GUILayout.Button("No")) { b = StandardButton.No; } if (GUILayout.Button("Cancel")) { b = StandardButton.Cancel; } }); } GUI.FocusWindow(id); GUI.BringWindowToFront(id); if (isDrag) { GUI.DragWindow(new Rect(0, 0, 10000, 20)); } if (QEditorEvent.IsKeyDown()) { if (QEditorEvent.GetKeyCode(KeyCode.Return)) { b = StandardButton.OK; } else if (QEditorEvent.GetKeyCode(KeyCode.Escape)) { b = StandardButton.Cancel; } } }, label); GUI.enabled = false; return(b); }