public override void OnGUI() { base.OnGUI(); //CheckDoc MarkDownDoc doc = null; if (string.IsNullOrEmpty(CurrentDocName)) { if (Docs.TryGetValue("Index", out doc)) { CurrentDocName = "Index"; } } else { doc = Docs[CurrentDocName]; if (Event.current.type == EventType.Layout) { if (DocPages.Count > 0) { var oldDoc = Docs[DocPages.Peek()]; if (oldDoc.datas.Count > 0) { oldDoc.Release(); } } if (doc.datas.Count == 0) { doc.Load(); } else { if (AutoRefresh && doc.RawDoc.text != doc.rawDoc) { doc.Release(); doc.rawDoc = doc.RawDoc.text; doc.Load(); } } } } //DrawDoc if (doc != null) { //ToolBar ToolBar(); //DocContent EditorGUI.DrawRect(DrawRect, ColorPalette.Get(ColorSettings, "BackGround", Color.white)); v = GUILayout.BeginScrollView(v); { if (searched != null) { if (Event.current.type == EventType.Repaint) { EditorGUI.DrawRect(searched.drawRect, ColorPalette.Get(ColorSettings, "HightLight", Color.white)); } if (Search.Current.IsNullOrEmpty()) { searched = null; } } EditorMarkDownDrawer.DrawDoc(doc, changePage, changeDoc, window.Repaint); } GUILayout.EndScrollView(); if (Event.current.type == EventType.Repaint) { DrawRect = GUILayoutUtility.GetLastRect(); } } else { EditorGUILayout.SelectableLabel("Can't find Index.md Document at :" + PathTools.RelativeAssetPath(this.GetType(), RelativePath)); EditorGUILayout.SelectableLabel("First you should create default page"); if (GUILayout.Button("CreateReadMe")) { if (EditorUtility.DisplayDialog("CreateIndex.md", "After create .md file,you have to reopen this editorwindow.", "OK", "Cancel")) { //Template string[] assets = AssetDatabase.FindAssets("TMP_ReadMe"); TextAsset text = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GUIDToAssetPath(assets[0])); // var DirRoot = PathTools.RelativeAssetPath(this.GetType(), RelativePath); var FileDirRoot = Directory.GetParent(DirRoot).FullName + @"\" + Path.GetFileName(DirRoot); if (!Directory.Exists(FileDirRoot)) { Directory.CreateDirectory(FileDirRoot); } FileTools.WriteAllText(FileDirRoot + "/Index.md", text.text); AssetDatabase.Refresh(); window.Close(); } } } //PingDocScript if (EditScript) { GUILayout.BeginHorizontal(); { AutoRefresh = GUILayout.Toggle(AutoRefresh, "自动刷新"); OnGUIUtility.ScriptField("Editor Script", this.GetType()); } GUILayout.EndHorizontal(); } }
public override void OnGUI() { base.OnGUI(); Title("ScriptField"); v = GUILayout.BeginScrollView(v); OnGUIUtility.ScriptField("this Script", GetType()); Title("EditorPrefsFoldoutGroup"); if (OnGUIUtility.EditorPrefsFoldoutGroup("FoldoutGroup")) { GUILayout.Label("FoldoutContent"); GUILayout.Label("FoldoutContent"); GUILayout.Label("FoldoutContent"); } Title("ObjectPopupWindow"); if (GUILayout.Button("ObjectPopupWindow.Show")) { ObjectPopupWindow.Show(this); } Title("SelectWindow"); if (GUILayout.Button("SelectWindow<T>.Show")) { SelectWindow <string> .Show(strlist, "1"); } if (SelectWindow <string> .CanPick("1")) { var t = SelectWindow <string> .GetPick(); Debug.Log(t); } Title("OnGUIUtility.Search"); var s = search.OnToolbarGUI(); Title("OnGUIUtility.Zone_Divide2Horizontal"); zone_Horizon.OnGUILayout(window.Repaint, () => { GUILayout.Button("1"); GUILayout.Button("1"); GUILayout.Button("1"); GUILayout.Button("1"); OnGUIUtility.Debug.HolderBox(); }, () => { SubZone_Horizon.OnGUILayout(window.Repaint, () => { GUILayout.Button("2"); GUILayout.Button("2"); OnGUIUtility.Debug.HolderBox(); GUILayout.Button("2"); SubZOne_Vertical.OnGUILayout(window.Repaint, () => { GUILayout.Button("3"); GUILayout.Button("3"); OnGUIUtility.Debug.HolderBox(); GUILayout.Button("3"); }, () => { GUILayout.Button("3"); OnGUIUtility.Debug.HolderBox(); GUILayout.Button("3"); }); }, () => { GUILayout.Button("2"); OnGUIUtility.Debug.HolderBox(); GUILayout.Button("2"); }); }); EditorGUILayout.MinMaxSlider("111", ref min, ref max, 0, 100); Title("SeanlibEditor.Styles"); GUILayout.Button("SeanLibEditor.styles.Area", SeanLibEditor.styles.ExtendArea, GUILayout.Width(200)); GUILayout.Button("SeanLibEditor.styles.Group", SeanLibEditor.styles.ExtendGroup, GUILayout.Width(200)); GUILayout.Button("SeanLibEditor.styles.Title", SeanLibEditor.styles.Title, GUILayout.Width(200)); GUILayout.EndScrollView(); Title("GUIGifDrawer.OnGUI"); gifDrawer.OnGUI(this.window.Repaint); gifDrawer1.OnGUI(this.window.Repaint); }