Example #1
0
    protected override void BuildSelectionTree(OdinMenuTree tree)
    {
        // Setup
        tree.Config.DrawSearchToolbar              = true;
        tree.Config.UseCachedExpandedStates        = false;
        tree.Selection.SupportsMultiSelect         = false;
        tree.Config.DefaultMenuStyle.IndentAmount += 13;

        this.staticMethodMenuItemStyle             = tree.Config.DefaultMenuStyle.Clone();
        this.staticMethodMenuItemStyle.IconPadding = 0;
        this.staticMethodMenuItemStyle.Offset     -= this.staticMethodMenuItemStyle.IconSize;

        // Add methods
        if (this.gameObjectTarget)
        {
            this.AddMethods(tree, typeof(GameObject), this.gameObjectTarget, Flags.InstancePublic);
            this.AddMethods(tree, typeof(GameObject), null, Flags.StaticAnyVisibility);

            var components = this.gameObjectTarget.GetComponents(typeof(Component));
            foreach (var c in components)
            {
                this.AddMethods(tree, c.GetType(), c, Flags.InstancePublic);
                this.AddMethods(tree, c.GetType(), null, Flags.StaticAnyVisibility);
            }
        }
        else if (this.target)
        {
            this.AddMethods(tree, this.target.GetType(), this.target, Flags.InstancePublic);
            this.AddMethods(tree, this.target.GetType(), null, Flags.StaticAnyVisibility);
        }
        else
        {
            // If there is no target provided then just show static methods from UnityEngine.Object?
            this.AddMethods(tree, typeof(UnityEngine.Object), null, Flags.StaticPublic);

            // Include others?
            // this.AddMethods(tree, typeof(UnityEngine.SceneManagement.SceneManager), null, Flags.StaticPublic);
        }

        // Add icons
        foreach (var item in tree.EnumerateTree())
        {
            if (item.Value is DelegateInfo)
            {
                continue;
            }
            if (item.ChildMenuItems.Count == 0)
            {
                continue;
            }
            var child = item.ChildMenuItems[0];
            if (child.Value is DelegateInfo)
            {
                var del = (DelegateInfo)child.Value;
                item.IconGetter = () => GUIHelper.GetAssetThumbnail(null, del.Method.DeclaringType, true);
            }
        }

        // Expand first, if there is only one root menu item.
        if (tree.MenuItems.Count == 1)
        {
            tree.MenuItems[0].Toggled = true;
        }
    }
 public MyCustomMenuItem(OdinMenuTree tree, SomeCustomClass instance) : base(tree, instance.Name, instance)
 {
     this.instance = instance;
 }
Example #3
0
 protected override void BuildSelectionTree(OdinMenuTree tree)
 {
     tree.Config.DrawSearchToolbar      = false;
     tree.Selection.SupportsMultiSelect = false;
     tree.Add("新建", 1);
 }
Example #4
0
 public void CreateItem <T>(T i, ref OdinMenuTree t) where T : ItemConfig <T>
 {
     i.物品ID = _tree.MenuItems.Count + 1;
     _tree.Add("New " + typeof(T).Name, i);
     _tree.MenuItems[_tree.MenuItems.Count - 1].Select();
 }
Example #5
0
 protected override void BuildSelectionTree(OdinMenuTree tree)
 {
     tree.AddRange(_list, x => Convert.ToString(x));
 }
Example #6
0
 public virtual void Setup(OdinMenuTree tree)
 {
 }
Example #7
0
 protected abstract void AddTree(OdinMenuTree tree);
Example #8
0
 /// <summary>
 /// 单 Class 单个添加
 /// </summary>
 /// <typeparam name="T">那个类</typeparam>
 /// <param name="tree">树</param>
 /// <param name="subString">菜单项名</param>
 /// <param name="color">字体颜色</param>
 protected void AddNew <R>(OdinMenuTree tree, string subString, MyEnumColor color = MyEnumColor.Blue)
     where R : new()
 {
     tree.AddObjectAtPath(subString, MyType.NewTypeClass <R>(), false, color);
 }
Example #9
0
 public void Setup(OdinMenuTree tree) =>
 _templatesPath = EditorPrefs.GetString(TEMPLATES_PATH_KEY, null);
Example #10
0
        public void Update()
        {
            List <DisplayOptions> displayOptions = AllDisplayOptions.Where(option => (this.Display & option) == option).ToList();

            // Create/adjust columns
            if (this.columns == null)
            {
                this.columns = new ResizableColumn[displayOptions.Count];
            }
            else
            {
                Array.Resize(ref this.columns, displayOptions.Count);
            }

            for (int i = 0; i < displayOptions.Count; i++)
            {
                this.columns[i] = this.GetColumn(displayOptions[i]);
            }

            // Create tree
            {
                this.Tree = new OdinMenuTree();
                this.Tree.Config.AutoHandleKeyboardNavigation = true;
                this.Tree.Config.UseCachedExpandedStates      = false;
                this.Tree.Config.EXPERIMENTAL_INTERNAL_DrawFlatTreeFastNoLayout = true;
                this.Tree.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle;

                int itemCount = 0;

                foreach (ValidationProfileResult profileResult in this.ProfileResults)
                {
                    foreach (ValidationResult validationResult in profileResult.Results)
                    {
                        if (validationResult.ResultType != ValidationResultType.Error && validationResult.ResultType != ValidationResultType.Warning)
                        {
                            continue;
                        }

                        ValidationInfoMenuItem menuItem = new ValidationInfoMenuItem(this.Tree, validationResult, profileResult, this.columns, this.Display, itemCount++);
                        this.Tree.MenuItems.Add(menuItem);
                    }
                }

                this.Tree.Selection.SelectionChanged += changeEvent =>
                {
                    if (changeEvent != SelectionChangedType.ItemAdded)
                    {
                        return;
                    }

                    if (this.OnProfileResultSelected != null)
                    {
                        ValidationInfoMenuItem  menuItem      = this.Tree.Selection.Last() as ValidationInfoMenuItem;
                        ValidationProfileResult profileResult = menuItem.ProfileResult;

                        this.OnProfileResultSelected(profileResult);
                    }
                };
            }

            if (this.SortBy != DisplayOptions.None)
            {
                this.Sort();
            }
        }
Example #11
0
 public void Setup(OdinMenuTree tree) =>
 _packages = AssetUtilities.GetAllAssetsOfType <Package>().ToArray();
Example #12
0
        protected override OdinMenuTree BuildMenuTree()
        {
            var tree = new OdinMenuTree();

            return(tree);
        }
Example #13
0
 protected virtual void BuildFixedMenus(OdinMenuTree odinMenuTree)
 {
 }