Ejemplo n.º 1
0
        protected override OdinMenuTree BuildMenuTree()
        {
            AddTreeElement();
            var tree = new OdinMenuTree();

            tree.DefaultMenuStyle.IconSize  = 15;
            tree.Config.DrawSearchToolbar   = true;
            tree.Config.SearchToolbarHeight = 30;
            tree.DefaultMenuStyle.Height    = 25;
            foreach (var i in dic)
            {
                if (i.Value == null || i.Value.Count == 0)
                {
                    tree.Add(i.Key, null);
                }
                else
                {
                    foreach (var x in i.Value)
                    {
                        var key = i.Key + "/" + x._name;
                        tree.Add(key, x, x.icon);
                    }
                }
            }
            tree.EnumerateTree().Where(x => x.Value as Element).ForEach(AddDragHandles);
            tree.SortMenuItemsByName();
            return(tree);
        }
Ejemplo n.º 2
0
        private SomeData someData = new SomeData(); // Take a look at SomeData.cs to see how serialization works in Editor Windows.

        protected override OdinMenuTree BuildMenuTree()
        {
            OdinMenuTree tree = new OdinMenuTree(supportsMultiSelect: true)
            {
                { "Home", this, EditorIcons.House },                                                                           // Draws the this.someData field in this case.
                { "Odin Settings", null, EditorIcons.SettingsCog },
                { "Odin Settings/Color Palettes", ColorPaletteManager.Instance, EditorIcons.EyeDropper },
                { "Odin Settings/AOT Generation", AOTGenerationConfig.Instance, EditorIcons.SmartPhone },
                { "Player Settings", Resources.FindObjectsOfTypeAll <PlayerSettings>().FirstOrDefault() },
                { "Some Class", this.someData }
            };

            tree.AddAllAssetsAtPath("Odin Settings/More Odin Settings", "Plugins/Sirenix", typeof(ScriptableObject), true)
            .AddThumbnailIcons();

            tree.AddAssetAtPath("Odin Getting Started", "Plugins/Sirenix/Getting Started With Odin.asset");

            tree.MenuItems.Insert(2, new OdinMenuItem(tree, "Menu Style", tree.DefaultMenuStyle));

            tree.Add("Menu/Items/Are/Created/As/Needed", new GUIContent());
            tree.Add("Menu/Items/Are/Created", new GUIContent("And can be overridden"));

            tree.SortMenuItemsByName();

            // As you can see, Odin provides a few ways to quickly add editors / objects to your menu tree.
            // The API also gives you full control over the selection, etc..
            // Make sure to check out the API Documentation for OdinMenuEditorWindow, OdinMenuTree and OdinMenuItem for more information on what you can do!

            return(tree);
        }
Ejemplo n.º 3
0
        protected override OdinMenuTree BuildMenuTree()
        {
            this.MenuWidth     = 270;
            this.WindowPadding = Vector4.zero;

            OdinMenuTree tree = new OdinMenuTree(false);

            tree.Config.DrawSearchToolbar = true;
            tree.DefaultMenuStyle         = OdinMenuStyle.TreeViewStyle;
            tree.AddRange(scriptableObjectTypes.Where(x => !x.IsAbstract), GetMenuPathForType).AddThumbnailIcons();
            tree.SortMenuItemsByName();
            tree.Selection.SelectionConfirmed += x => this.CreateAsset();
            tree.Selection.SelectionChanged   += e =>
            {
                if (this.previewObject && !AssetDatabase.Contains(this.previewObject))
                {
                    DestroyImmediate(this.previewObject);
                }

                if (e != SelectionChangedType.ItemAdded)
                {
                    return;
                }

                var t = this.SelectedType;
                if (t != null && !t.IsAbstract)
                {
                    this.previewObject = CreateInstance(t) as ScriptableObject;
                }
            };

            return(tree);
        }
Ejemplo n.º 4
0
        protected override OdinMenuTree BuildMenuTree()
        {
            OdinMenuTree tree = new OdinMenuTree
            {
                { "Path Settings", FindPathSettings() }
            };

            tree.AddAllAssetsAtPath("Path Settings", "Assets/Continuous Mode/Data/Path Zones", typeof(ProceduralZone));
            //tree.AddRange(ProceduralPathSettings.Instance.Zones, (obj) => ("Path Settings/Zone " + ProceduralPathSettings.Instance.Zones.Count));
            tree.SortMenuItemsByName();
            //tree.
            return(tree);
        }
Ejemplo n.º 5
0
    protected override OdinMenuTree BuildMenuTree()
    {
        OdinMenuTree tree = new OdinMenuTree(true);

        tree.DefaultMenuStyle.IconSize = 28.00f;
        tree.Config.DrawSearchToolbar  = true;

        var evs = GetSequences();

        Dictionary <string, int> sqAmount = new Dictionary <string, int>();

        for (int i = 0; i < evs.Count; i++)
        {
            string sqName = evs[i].id != "" ? evs[i].name + ": " + evs[i].id : evs[i].name;

            if (sqAmount.ContainsKey(sqName))
            {
                sqAmount[sqName] += 1;
            }
            else
            {
                sqAmount.Add(sqName, 0);
            }

            if (sqAmount[sqName] != 0)
            {
                tree.Add(sqName + " (" + sqAmount[sqName] + ")", evs[i]);
            }
            else
            {
                tree.Add(sqName, evs[i]);
            }
        }

        tree.SortMenuItemsByName();
        //tree.MenuItems.AddIcons(EditorIcons.Play);

        return(tree);
    }
    protected override OdinMenuTree BuildMenuTree()
    {
        MenuWidth     = 300;//菜单的宽度
        WindowPadding = Vector4.zero;

        OdinMenuTree tree = new OdinMenuTree(false);                 //不支持多选

        tree.Config.DrawSearchToolbar = true;                        //开启搜索状态
        tree.DefaultMenuStyle         = OdinMenuStyle.TreeViewStyle; //菜单设置成树形模式

        //筛选所有非抽象的类 并获取对应的路径
        tree.AddRange(scriptableObjectTypes.Where(x => !x.IsAbstract), GetMenuPathForType).AddThumbnailIcons();
        tree.SortMenuItemsByName();
        tree.Selection.SelectionConfirmed += x =>
        {
            Debug.Log($"双击确认并创建:{x}");
            this.CreateAsset();
        };
        tree.Selection.SelectionChanged += e =>
        {
            //每当选择发生更改时发生进行回调2次,一次SelectionCleared 一次是ItemAdded
            if (this.previewObject && !AssetDatabase.Contains(this.previewObject))
            {
                DestroyImmediate(previewObject);
            }

            if (e != SelectionChangedType.ItemAdded)
            {
                return;
            }

            var t = SelectedType;
            if (t != null && !t.IsAbstract)
            {
                previewObject = CreateInstance(t) as ScriptableObject;
            }
        };
        return(tree);
    }
Ejemplo n.º 7
0
        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);
        }
        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);
        }