void AddAllAssetsAtPath( OdinMenuTree tree, string assetFolderPath, Type type) { var strings = AssetDatabase.GetAllAssetPaths().Where(x => x.StartsWith(assetFolderPath, StringComparison.InvariantCultureIgnoreCase)); var odinMenuItemSet = new HashSet <OdinMenuItem>(); foreach (var str1 in strings) { var asset = AssetDatabase.LoadAssetAtPath(str1, type); var path = string.Empty; var name = string.Empty; var str2 = string.Empty; if (asset == null) { //it's a directory str2 = str1.Substring(assetFolderPath.Length); int length = str2.LastIndexOf('/'); if (length == -1) { path = string.Empty; name = str2; } else { path = str2.Substring(0, length); name = str2.Substring(length + 1); } if (name == string.Empty) { continue; } tree.AddMenuItemAtPath(odinMenuItemSet, path, new OdinMenuItem(tree, name, new FolderHolder(path, name))); continue; } var withoutExtension = System.IO.Path.GetFileNameWithoutExtension(str1); str2 = (PathUtilities.GetDirectoryName(str1).TrimEnd('/') + "/").Substring(assetFolderPath.Length); if (str2.Length != 0) { path = path.Trim('/') + "/" + str2; } path = path.Trim('/') + "/" + withoutExtension; SplitMenuPath(path, out path, out name); var menuItem = new OdinMenuItem(tree, name, new DataNodeHolder(path, name, (DataNode)asset)); tree.AddMenuItemAtPath(odinMenuItemSet, path, menuItem); AddDragHandles(menuItem); } }
/// <summary> /// 单 Class 的按组添加 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tree"></param> /// <param name="bigStr"></param> /// <param name="subString"></param> /// <param name="color"></param> protected void AddNew <R>(OdinMenuTree tree, string bigStr, string subString, MyEnumColor color = MyEnumColor.Blue) where R : new() { OdinMenuItem item1 = new OdinMenuItem(tree, subString, MyType.NewTypeClass <R>()); item1.TextColor = color; tree.AddMenuItemAtPath(bigStr, item1); }
protected override OdinMenuTree BuildMenuTree() { var tree = new OdinMenuTree(true); var customMenuStyle = new OdinMenuStyle { BorderPadding = 0f, AlignTriangleLeft = true, TriangleSize = 16f, TrianglePadding = 0f, Offset = 20f, Height = 23, IconPadding = 0f, BorderAlpha = 0.323f }; tree.DefaultMenuStyle = customMenuStyle; tree.Config.DrawSearchToolbar = true; // Adds the custom menu style to the tree, so that you can play around with it. // Once you are happy, you can press Copy C# Snippet copy its settings and paste it in code. // And remove the "Menu Style" menu item from the tree. tree.AddObjectAtPath("Menu Style", tree.DefaultMenuStyle) .AddThumbnailIcons(); for (int i = 0; i < 5; i++) { var customObject = new SomeCustomClass() { Name = i.ToString() }; var customMenuItem = new MyCustomMenuItem(tree, customObject); tree.AddMenuItemAtPath("Custom Menu Items", customMenuItem); } tree.AddAllAssetsAtPath("Scriptable Objects in Plugins Tree", "Plugins", typeof(ScriptableObject), true, false) .AddThumbnailIcons() .SortMenuItemsByName(); tree.AddAllAssetsAtPath("Scriptable Objects in Plugins Flat", "Plugins", typeof(ScriptableObject), true, true) .AddThumbnailIcons(true) .SortMenuItemsByName(); tree.AddAllAssetsAtPath("Only Configs has Icons", "Plugins/Sirenix", true, false) .Where(x => x.ObjectInstance as ScriptableObject) .AddThumbnailIcons(); return(tree); }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var allTrickOverViewInfo in AllTrickOverViewExamples) { TrickOverViewInfo trickOverViewInfo = (allTrickOverViewInfo.Value).GetTrickOverViewInfo(); OdinMenuItem menuItem = new OdinMenuItem(tree, trickOverViewInfo.Name, allTrickOverViewInfo.Key) { Value = allTrickOverViewInfo.Key, SearchString = trickOverViewInfo.Name + trickOverViewInfo.Description }; tree.AddMenuItemAtPath(trickOverViewInfo.Category, menuItem); } tree.MenuItems.Sort(AllTrickOverViewUtilities.CategorySorter); tree.MarkDirty(); }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var a in GetAllOdinAttributes()) { string search = a.Name; // TODO: tags? foreach (var c in GetAttributeCategories(a)) { var item = new OdinMenuItem(tree, a.GetNiceName().Replace("Attribute", "").SplitPascalCase(), a) { Value = a, Icon = GetAttributeIcon(a), SearchString = search, }; search = null; // Only allow the user to find the first item of an attribute by search. tree.AddMenuItemAtPath(c, item); } } tree.SortMenuItemsByName(); }
protected override OdinMenuTree BuildMenuTree() { var tree = new OdinMenuTree(true) { DefaultMenuStyle = { IconSize = 28.00f }, Config = { DrawSearchToolbar = true } }; if (SODatabaseSettings.Path == string.Empty) { inSettings = true; tree.AddMenuItemAtPath(new HashSet <OdinMenuItem>(), string.Empty, new OdinMenuItem(tree, "Settings", SODatabaseSettings.Instance)); return(tree); } AddAllAssetsAtPath(tree, SODatabaseSettings.Path, typeof(DataNode)); Texture folderIcon = (Texture2D)AssetDatabase.LoadAssetAtPath("Packages/com.nuclearband.sodatabase/Editor/folderIcon.png", typeof(Texture2D)); tree.EnumerateTree().AddIcons <FolderHolder>(x => folderIcon); tree.SortMenuItemsByName(); tree.Selection.SelectionChanged += SelectionChanged; return(tree); }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var a in GetAllOdinAttributes()) { // TODO: tags? string search = a.Name + " " + string.Join(" ", GetAttributeExampleInfos(a).Select(x => x.Name).ToArray()); foreach (var c in GetAttributeCategories(a)) { var item = new OdinMenuItem(tree, a.GetNiceName().Replace("Attribute", "").SplitPascalCase(), a) { Value = a, SearchString = search, }; search = null; // Only allow the user to find the first item of an attribute by search. tree.AddMenuItemAtPath(c, item); } } tree.MenuItems.Sort(CategorySorter); tree.MarkDirty(); }
protected override OdinMenuTree BuildMenuTree() { var tree = new OdinMenuTree(true); tree.Config.DrawSearchToolbar = true; tree.Config.SearchToolbarHeight = (int)_editorInterface.toolbarHeight + 2; string path = ResourceManager.ActorEditorPath; string[] assets = Directory.GetFiles(path, "*.asset"); for (int i = 0; i < assets.Length; i++) { var asset = ResourceManager.LoadResource <NodeCanvas>(assets[i]); SVNMenuItem item = new SVNMenuItem(tree, asset.name, asset.savePath); tree.AddMenuItemAtPath("", item); EditorUtility.DisplayProgressBar(TITLE, asset.name, (i + 1f) / assets.Length); } EditorUtility.ClearProgressBar(); tree.SortMenuItemsByName(); tree.Selection.SelectionConfirmed += SelectionConfirmed; return(tree); }