diff --git a/Source/Editor/Windows/ContentWindow.ContextMenu.cs b/Source/Editor/Windows/ContentWindow.ContextMenu.cs index 7368c4efd..0bff62ab4 100644 --- a/Source/Editor/Windows/ContentWindow.ContextMenu.cs +++ b/Source/Editor/Windows/ContentWindow.ContextMenu.cs @@ -1,6 +1,7 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. using System; +using System.Collections.Generic; using FlaxEditor.Content; using FlaxEditor.GUI.ContextMenu; using FlaxEngine; @@ -16,6 +17,40 @@ namespace FlaxEditor.Windows /// public event Action ContextMenuShow; + private readonly string _animationMenuName = "Animation"; + private readonly string _materialMenuName = "Materials"; + private readonly string _particleMenuName = "Particles"; + private readonly string _physicsMenuName = "Physics"; + + private readonly List _animationGroupNames = new List() + { + "Animation", + "Animation Graph", + "Animation Graph Function", + "Skeleton Mask", + "Scene Animation", + }; + + private readonly List _particleGroup = new List() + { + "Particle Emitter", + "Particle Emitter Function", + "Particle System", + }; + + private readonly List _materialGroup = new List() + { + "Material", + "Material Function", + "Material Instance", + }; + + private readonly List _physicsGroup = new List() + { + "Collision Data", + "Physical Material", + }; + private void ShowContextMenuForItem(ContentItem item, ref Float2 location, bool isTreeNode) { Assert.IsNull(_newElement); @@ -159,7 +194,17 @@ namespace FlaxEditor.Windows var p = Editor.ContentDatabase.Proxy[i]; if (p.CanCreate(folder)) { - c.ContextMenu.AddButton(p.Name, () => NewItem(p)); + if (_animationGroupNames.Contains(p.Name)) + AddContentProxyToMenu(c.ContextMenu, p, _animationMenuName); + else if (_particleGroup.Contains(p.Name)) + AddContentProxyToMenu(c.ContextMenu, p, _particleMenuName); + else if (_materialGroup.Contains(p.Name)) + AddContentProxyToMenu(c.ContextMenu, p, _materialMenuName); + else if (_physicsGroup.Contains(p.Name)) + AddContentProxyToMenu(c.ContextMenu, p, _physicsMenuName); + else + c.ContextMenu.AddButton(p.Name, () => NewItem(p)); + newItems++; } } @@ -178,6 +223,21 @@ namespace FlaxEditor.Windows cm.Show(this, location); } + private void AddContentProxyToMenu(ContextMenu contextMenu, ContentProxy contentProxy, string menuName) + { + var childMenu = contextMenu.GetChildMenu(menuName); + if (childMenu == null) + { + var c = contextMenu.AddChildMenu(menuName); + c.ContextMenu.AutoSort = true; + c.ContextMenu.AddButton(contentProxy.Name, () => NewItem(contentProxy)); + } + else + { + childMenu.ContextMenu.AddButton(contentProxy.Name, () => NewItem(contentProxy)); + } + } + private void OnExpandAllClicked(ContextMenuButton button) { CurrentViewFolder.Node.ExpandAll();