Merge branch 'organized-content-new-cm' of https://github.com/Tryibion/FlaxEngine into Tryibion-organized-content-new-cm
This commit is contained in:
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="AnimationGraphFunction"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Animation/Animation Graph Function")]
|
||||
public class AnimationGraphFunctionProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="AnimationGraph"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Animation/Animation Graph")]
|
||||
public class AnimationGraphProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="Animation"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Animation/Animation")]
|
||||
public class AnimationProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace FlaxEditor.Content
|
||||
/// Context proxy object for C# script files.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||
[ContentContextMenu("New/C# Script")]
|
||||
public class CSharpScriptProxy : ScriptProxy
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="CollisionData"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Physics/Collision Data")]
|
||||
class CollisionDataProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace FlaxEditor.Content
|
||||
/// Context proxy object for C++ script files.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||
[ContentContextMenu("New/C++/C++ Script")]
|
||||
public class CppScriptProxy : CppProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -98,6 +99,7 @@ namespace FlaxEditor.Content
|
||||
/// Context proxy object for C++ Json Asset files.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||
[ContentContextMenu("New/C++/C++ Function Library")]
|
||||
public class CppStaticClassProxy : CppProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -115,6 +117,7 @@ namespace FlaxEditor.Content
|
||||
/// Context proxy object for C++ Json Asset files.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||
[ContentContextMenu("New/C++/C++ Json Asset")]
|
||||
public class CppAssetProxy : CppProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="GameplayGlobals"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Gameplay Globals")]
|
||||
public class GameplayGlobalsProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace FlaxEditor.Content
|
||||
/// Json assets proxy.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||
[ContentContextMenu("New/Json Asset")]
|
||||
public abstract class JsonAssetProxy : JsonAssetBaseProxy
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="MaterialFunction"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Material/Material Function")]
|
||||
public class MaterialFunctionProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="MaterialInstance"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Material/Material Instance")]
|
||||
public class MaterialInstanceProxy : BinaryAssetProxy
|
||||
{
|
||||
private MaterialPreview _preview;
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="Material"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Material/Material")]
|
||||
public class MaterialProxy : BinaryAssetProxy
|
||||
{
|
||||
private MaterialPreview _preview;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="ParticleEmitterFunction"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Particles/Particle Emitter Function")]
|
||||
public class ParticleEmitterFunctionProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="ParticleEmitter"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Particles/Particle Emitter")]
|
||||
public class ParticleEmitterProxy : BinaryAssetProxy
|
||||
{
|
||||
private ParticleEmitterPreview _preview;
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="ParticleSystem"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Particles/Particle System")]
|
||||
public class ParticleSystemProxy : BinaryAssetProxy
|
||||
{
|
||||
private ParticleSystemPreview _preview;
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
||||
/// Content proxy for <see cref="PrefabItem"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||
[ContentContextMenu("New/Prefab")]
|
||||
public sealed class PrefabProxy : JsonAssetBaseProxy
|
||||
{
|
||||
private PrefabPreview _preview;
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace FlaxEditor.Content
|
||||
/// Content proxy for <see cref="SceneItem"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||
[ContentContextMenu("New/Scene")]
|
||||
public sealed class SceneProxy : JsonAssetBaseProxy
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// Content proxy for json settings assets (e.g <see cref="GameSettings"/> or <see cref="TimeSettings"/>).
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.JsonAssetProxy" />
|
||||
[ContentContextMenu("New/Settings")]
|
||||
public class SettingsProxy : JsonAssetProxy
|
||||
{
|
||||
private readonly Type _type;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace FlaxEditor.Content
|
||||
/// Context proxy object for shader source files (represented by <see cref="ShaderSourceItem"/>).
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.ContentProxy" />
|
||||
[ContentContextMenu("New/Shader Source")]
|
||||
public class ShaderSourceProxy : ContentProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="SkeletonMask"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Animation/Skeleton Mask")]
|
||||
public class SkeletonMaskProxy : BinaryAssetProxy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
||||
/// A <see cref="VisualScript"/> asset proxy object.
|
||||
/// </summary>
|
||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||
[ContentContextMenu("New/Visual Script")]
|
||||
public class VisualScriptProxy : BinaryAssetProxy, IScriptTypesContainer
|
||||
{
|
||||
internal VisualScriptProxy()
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Create context menu
|
||||
ContextMenuButton b;
|
||||
ContextMenuChildMenu c;
|
||||
ContextMenu cm = new ContextMenu
|
||||
{
|
||||
Tag = item
|
||||
@@ -149,22 +148,77 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
cm.AddButton("New folder", NewFolder);
|
||||
}
|
||||
|
||||
c = cm.AddChildMenu("New");
|
||||
c.ContextMenu.Tag = item;
|
||||
c.ContextMenu.AutoSort = true;
|
||||
int newItems = 0;
|
||||
for (int i = 0; i < Editor.ContentDatabase.Proxy.Count; i++)
|
||||
|
||||
// loop through each proxy and user defined json type and add them to the context menu
|
||||
foreach (var type in Editor.CodeEditing.All.Get())
|
||||
{
|
||||
var p = Editor.ContentDatabase.Proxy[i];
|
||||
if (type.IsAbstract || !type.HasAttribute(typeof(ContentContextMenuAttribute), true) || Editor.CodeEditing.Actors.Get().Contains(type) || Editor.CodeEditing.Scripts.Get().Contains(type))
|
||||
continue;
|
||||
|
||||
ContentContextMenuAttribute attribute = null;
|
||||
foreach (var typeAttribute in type.GetAttributes(true))
|
||||
{
|
||||
if (typeAttribute is ContentContextMenuAttribute contentContextMenuAttribute)
|
||||
{
|
||||
attribute = contentContextMenuAttribute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ContentProxy p;
|
||||
if (type.Type.IsSubclassOf(typeof(ContentProxy)))
|
||||
{
|
||||
p = Editor.ContentDatabase.Proxy.Find(T => T.GetType() == type.Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
// user can use attribute to put their own assets into the content context menu
|
||||
var generic = typeof(SpawnableJsonAssetProxy<>).MakeGenericType(type.Type);
|
||||
var instance = Activator.CreateInstance(generic);
|
||||
p = instance as AssetProxy;
|
||||
}
|
||||
|
||||
if (p == null)
|
||||
continue;
|
||||
|
||||
// create menus
|
||||
if (p.CanCreate(folder))
|
||||
{
|
||||
c.ContextMenu.AddButton(p.Name, () => NewItem(p));
|
||||
newItems++;
|
||||
var splitPath = attribute.Path.Split('/');
|
||||
ContextMenuChildMenu childCM = null;
|
||||
bool mainCM = true;
|
||||
for (int i = 0; i < splitPath?.Length; i++)
|
||||
{
|
||||
if (i == splitPath.Length - 1)
|
||||
{
|
||||
if (mainCM)
|
||||
{
|
||||
cm.AddButton(splitPath[i].Trim(), () => NewItem(p));
|
||||
mainCM = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
childCM?.ContextMenu.AddButton(splitPath[i].Trim(), () => NewItem(p));
|
||||
childCM.ContextMenu.AutoSort = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mainCM)
|
||||
{
|
||||
childCM = cm.GetOrAddChildMenu(splitPath[i].Trim());
|
||||
mainCM = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
childCM = childCM?.ContextMenu.GetOrAddChildMenu(splitPath[i].Trim());
|
||||
}
|
||||
childCM.ContextMenu.AutoSort = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Enabled = newItems > 0;
|
||||
|
||||
|
||||
if (folder.CanHaveAssets)
|
||||
{
|
||||
cm.AddButton("Import file", () =>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/// <summary>
|
||||
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
|
||||
/// </summary>
|
||||
API_CLASS() class FLAXENGINE_API PhysicalMaterial final : public ISerializable
|
||||
API_CLASS(Attributes = "ContentContextMenu(\"New/Physics/Physical Material\")") class FLAXENGINE_API PhysicalMaterial final : public ISerializable
|
||||
{
|
||||
API_AUTO_SERIALIZATION();
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicalMaterial);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// This attribute is used to show content items that can be created in the content browser context menu. Separate the subcontext menus with a /.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ContentContextMenuAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// The path to be used in the context menu
|
||||
/// </summary>
|
||||
public string Path;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentContextMenuAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to use to create the context menu</param>
|
||||
public ContentContextMenuAttribute(string path)
|
||||
{
|
||||
Path = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user