public static void DrawGUI() { #if UNITY_2018_3_OR_NEWER using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("add")) { var m = new GenericMenu(); var list = AssemblieUtils.SubclassesOf <EditorWindow>() .OrderBy(x => x.Assembly.FullName) .ThenBy(x => x.FullName); foreach (var p in list) { var asmName = p.Assembly.FullName.Split(',')[0]; m.AddItem($"{asmName[ 0 ]}/{asmName}/{p.Name}", reg, p); } m.DropDownAtMousePosition(); void reg(object context) { var t = (Type)context; if (E.i.utilityWindowSettingsData.Find(x => x.TypeFullName == t.FullName) == null) { E.i.utilityWindowSettingsData.Add(new UtilityWindowSettingsData { Enable = true, TypeFullName = t.FullName }); } CheckNullType(); E.Save(); } } if (GUILayout.Button("remove")) { E.i.utilityWindowSettingsData = new List <UtilityWindowSettingsData>(); } } UtilityWindowSettingsData _remove = null; foreach (var p in E.i.utilityWindowSettingsData) { EditorGUI.BeginChangeCheck(); p.Enable = HEditorGUILayout.ToggleBox($"{p.GetUtilityType().FullName}", p.Enable, EditorIcon.minus, OnButton); if (EditorGUI.EndChangeCheck()) { E.Save(); } void OnButton() { _remove = p; } } if (_remove != null) { E.i.utilityWindowSettingsData.Remove(_remove); E.Save(); } #endif }
///////////////////////////////////////// protected override void OnContextClickedItem(PackageTreeItem item) { var ev = Event.current; var pos = ev.mousePosition; var m = new GenericMenu(); m.AddItem(SS._Install, () => { //選択パッケージをインストール指定する(); PackageDatabaseUtils.InstallFromUrl(item.value); }); m.DropDownAtMousePosition(); }
static void OnProjectFolderPreset() { var m = new GenericMenu(); m.AddItem(S._Makepackagesettings, () => { E.i.projectSettingsPath = "6763de3f012135f439fea4e446738691"; E.Save(); }); m.AddItem(S._UseProjectSettings, () => { E.i.projectSettingsPath = "ProjectSettings"; E.Save(); }); m.DropDownAtMousePosition(); }
static void DrawContentConfig() { ScopeChange.Begin(); //PB.i.enableAssetBundleBuild = HEditorGUILayout.ToggleLeft( S._EnableAssetBundleBuild, PB.i.enableAssetBundleBuild ); //HEditorGUI.DrawDebugRectAtLastRect(); PB.i.enableOldStyleProjectSettings = HEditorGUILayout.ToggleLeft(S._Usingtheold_styleProjectSettings, PB.i.enableOldStyleProjectSettings); GUILayout.Space(8); PB.i.enableExlusionAssets = HEditorGUILayout.ToggleLeft(S._Enablingassetexclusionatbuildtime, PB.i.enableExlusionAssets); GUILayout.Label(S._ExclusionAssetsList, EditorStyles.boldLabel); if (s_exclusionContents == null) { if (PB.i.exclusionAssets == null) { PB.i.exclusionAssets = new List <PB.ExclusionSets>(); } //foreach(var p in PB.i.exclusionAssets ) { // Debug.Log( GUIDUtils.GetAssetPath( p.GUID ) ); //} s_exclusionContents = PB.i.exclusionAssets.Select(x => x.GUID.ToAssetPath()).OrderBy(value => value).Select(x => new GUIContent(x, AssetDatabase.GetCachedIcon(x))).ToArray(); } int removeIndex = -1; ScopeVertical.Begin(EditorStyles.helpBox); for (int i = 0; i < s_exclusionContents.Length; i++) { var s = s_exclusionContents[i]; ScopeHorizontal.Begin(); GUILayout.Label(EditorHelper.TempContent(""), GUILayout.ExpandWidth(true), GUILayout.Height(18)); ScopeHorizontal.End(); var rc = GUILayoutUtility.GetLastRect(); GUI.Box(rc, "", Styles.projectBrowserHeaderBgMiddle); GUI.Label(rc, s, Styles.labelAndIcon); rc.x = rc.xMax - 16; rc.width = 16; if (HEditorGUI.IconButton(rc, EditorIcon.minus)) { removeIndex = i; } } GUILayout.FlexibleSpace(); if (0 <= removeIndex) { var findGUID = s_exclusionContents[removeIndex].text.ToGUID(); var rIndex = PB.i.exclusionAssets.FindIndex(x => x.GUID == findGUID); PB.i.exclusionAssets.RemoveAt(rIndex); s_exclusionContents = null; s_changed = true; } ScopeVertical.End(); var dropRc = GUILayoutUtility.GetLastRect(); var evt = Event.current; switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: if (!dropRc.Contains(evt.mousePosition)) { break; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; void AddFiles(params string[] paths) { PB.i.exclusionAssets.AddRange(paths.Select(x => new PB.ExclusionSets(x.ToGUID(), x)).ToArray()); PB.i.exclusionAssets = PB.i.exclusionAssets.Distinct(x => x.GUID).ToList(); PB.Save(); } string[] DirFiles(string path) { return(DirectoryUtils.GetFiles(path, "*", SearchOption.AllDirectories).Where(x => x.Extension() != ".meta").ToArray()); } if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); if (DragAndDrop.paths.Length == 1) { if (Directory.Exists(DragAndDrop.paths[0])) { var m = new GenericMenu(); m.AddItem(S._Registerasafolder, false, (context) => { AddFiles((string)context); }, DragAndDrop.paths[0]); m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => { AddFiles(DirFiles((string)context)); ; }, DragAndDrop.paths[0]); m.DropDownAtMousePosition(); } else { AddFiles(DragAndDrop.paths); } } else { bool dirChekc = false; foreach (var s in DragAndDrop.paths) { if (Directory.Exists(s)) { dirChekc = true; break; } } if (dirChekc) { var m = new GenericMenu(); m.AddItem(S._Registerasafolder, false, (context) => { AddFiles((string[])context); }, DragAndDrop.paths); m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => { foreach (var s in ((string[])context)) { if (Directory.Exists(s)) { AddFiles(DirFiles(s)); } else { AddFiles(s); } } }, DragAndDrop.paths); m.DropDownAtMousePosition(); } else { AddFiles(DragAndDrop.paths); } } DragAndDrop.activeControlID = 0; s_exclusionContents = null; } s_changed = true; Event.current.Use(); break; } if (ScopeChange.End()) { s_changed = true; } }