public override void OnEnable(SeanLibManager drawer) { base.OnEnable(drawer); var docAssetDir = PathTools.RelativeAssetPath(this.GetType(), RelativePath); var subAssets = AssetDatabase.FindAssets("", new string[] { docAssetDir }); List <string> docPath = new List <string>(); foreach (var item in subAssets) { var assetPath = AssetDatabase.GUIDToAssetPath(item); if (Path.GetExtension(assetPath) == ".md") { docPath.Add(assetPath); } } foreach (var aPath in docPath) { var rawDoc = AssetDatabase.LoadAssetAtPath(aPath, typeof(TextAsset)) as TextAsset; var docName = aPath.Replace(docAssetDir + "/", "").Replace(".md", ""); //需要手动加载 var doc = new MarkDownDoc(aPath.Substring(0, aPath.LastIndexOf('/')), rawDoc, false); if (this.window is SeanLibDocHub) { doc.ColorSetting = ColorSettings; } Docs[docName] = doc; } if (SearchField) { Search.downOrUpArrowKeyPressed += () => { SearchNext(); }; } }
public virtual void OnEnable(SeanLibManager drawer) { window = drawer; if (UseIMGUI) { SetupIMGUI(); } else { SetupUIElements(); } }
public virtual void OnDisable() { window.EditorContent.Clear(); if (UseIMGUI) { } else { if (editorContent_styles) { window.EditorContent.styleSheets.Remove(editorContent_styles); editorContent_styles = null; } } window = null; }
public void RefreshTreeData(SeanLibManager drawer) { var editorTypes = AssemblyTool.FindTypesInCurrentDomainWhereAttributeIs <CustomSeanLibEditor>(); editorTypes.RemoveAll(e => ReflecTool.GetAttribute <CustomSeanLibEditor>(e).IsDoc != isdoc); editorTypes.Sort((l, r) => { return(ReflecTool.GetAttribute <CustomSeanLibEditor>(l).order - ReflecTool.GetAttribute <CustomSeanLibEditor>(r).order); }); editors = new List <SeanLibEditor>(editorTypes.Count); foreach (var item in editorTypes) { SeanLibEditor editor = ReflecTool.Instantiate(item) as SeanLibEditor; //editor.OnEnable(drawer); editors.Add(editor); } Reload(); }
public override void OnEnable(SeanLibManager drawer) { base.OnEnable(drawer); //Load Doc var docAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(PathTools.RelativeAssetPath(this.GetType(), DocDir + "/Index.md")); if (docAsset) { doc = new MarkDownDoc(DocDir, docAsset.text, true); } PackStorageDir = EditorUserSettings.GetConfigValue(packageKey); LocalLibDir = EditorUserSettings.GetConfigValue(localKey); ReadRemotePluginsFile(); ReadPackageFold(); ReadLocalPlugin(); RemotePlistEditor.OnEnable((info, index) => { OnGUIUtility.Vision.BeginBackGroundColor(index % 2 == 0 ? OnGUIUtility.Colors.dark : OnGUIUtility.Colors.light); { EditorGUILayout.BeginVertical(); if (OnGUIUtility.Foldout(info.Name, Styles.PackageTitle, GUILayout.ExpandWidth(true))) { info.Name = EditorGUILayout.DelayedTextField("Name", info.Name); info.URL = EditorGUILayout.TextField("URL", info.URL); info.version = (PluginVersion)EditorGUILayout.EnumPopup("Version", info.version); } EditorGUILayout.EndVertical(); } OnGUIUtility.Vision.EndBackGroundColor(); return(info); }, () => { return(new PluginInfo()); }, 1, "+Plugin"); }
public override void OnEnable(SeanLibManager drawer) { base.OnEnable(drawer); zone_Horizon.Area0Size = 200; zone_Horizon.min = 60; zone_Horizon.Max = 800; #region 列表Demo // Create some list of data, here simply numbers in interval [1, 1000] const int itemCount = 1000; var items = new List <string>(itemCount); for (int i = 1; i <= itemCount; i++) { items.Add(i.ToString()); } // The "makeItem" function will be called as needed // when the ListView needs more items to render Func <VisualElement> makeItem = () => new Button(); // As the user scrolls through the list, the ListView object // will recycle elements created by the "makeItem" // and invoke the "bindItem" callback to associate // the element with the matching data item (specified as an index in the list) Action <VisualElement, int> bindItem = (e, i) => { var btn = (e as Button); btn.text = items[i]; btn.clickable.clicked += () => Debug.Log(i); }; var listView = window.EditorContent.Q <ListView>(); listView.makeItem = makeItem; listView.bindItem = bindItem; listView.itemsSource = items; listView.selectionType = SelectionType.Multiple; // Callback invoked when the user double clicks an item listView.onItemChosen += obj => Debug.Log(obj); // Callback invoked when the user changes the selection inside the ListView listView.onSelectionChanged += objects => Debug.Log(objects); #endregion #region button // Action to perform when button is pressed. // Toggles the text on all buttons in 'container'. Action action = () => { Debug.Log("Button click"); }; // Get a reference to the Button from UXML and assign it its action. var uxmlButton = window.EditorContent.Q <Button>("the-uxml-button"); uxmlButton.clickable.clicked += () => action(); #endregion var DemoIMGUI = window.EditorContent.Q <IMGUIContainer>("IMGUI"); DemoIMGUI.onGUIHandler = OnGUI; gifDrawer.LoadGIF(PathTools.Asset2File(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("gif t:texture")[0]))); gifDrawer.Play(); gifDrawer1.LoadGIF(PathTools.Asset2File(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("gif t:texture")[0]))); gifDrawer1.Play(); }