changed to use attribute to add items to the content context menu, this also allows users to add their own items to the CM
This commit is contained in:
@@ -11,14 +11,12 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="AnimationGraphFunction"/> asset proxy object.
|
/// A <see cref="AnimationGraphFunction"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Animation/Animation Graph Function")]
|
||||||
public class AnimationGraphFunctionProxy : BinaryAssetProxy
|
public class AnimationGraphFunctionProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Animation Graph Function";
|
public override string Name => "Animation Graph Function";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Animation";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="AnimationGraph"/> asset proxy object.
|
/// A <see cref="AnimationGraph"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Animation/Animation Graph")]
|
||||||
public class AnimationGraphProxy : BinaryAssetProxy
|
public class AnimationGraphProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Animation Graph";
|
public override string Name => "Animation Graph";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Animation";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -14,13 +14,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="Animation"/> asset proxy object.
|
/// A <see cref="Animation"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Animation/Animation")]
|
||||||
public class AnimationProxy : BinaryAssetProxy
|
public class AnimationProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Animation";
|
public override string Name => "Animation";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Animation";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ namespace FlaxEditor.Content
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract string TypeName { get; }
|
public abstract string TypeName { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The category name used to sort in context menus
|
|
||||||
/// </summary>
|
|
||||||
public abstract string CategoryName { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if this proxy supports the given asset type id at the given path.
|
/// Checks if this proxy supports the given asset type id at the given path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -62,9 +62,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Audio Clip";
|
public override string Name => "Audio Clip";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Audio";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Context proxy object for C# script files.
|
/// Context proxy object for C# script files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||||
|
[ContentContextMenu("New/C# Script")]
|
||||||
public class CSharpScriptProxy : ScriptProxy
|
public class CSharpScriptProxy : ScriptProxy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -38,13 +38,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="CollisionData"/> asset proxy object.
|
/// A <see cref="CollisionData"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Physics/Collision Data")]
|
||||||
class CollisionDataProxy : BinaryAssetProxy
|
class CollisionDataProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Collision Data";
|
public override string Name => "Collision Data";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Physics";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Context proxy object for C++ script files.
|
/// Context proxy object for C++ script files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||||
|
[ContentContextMenu("New/C++/C++ Script")]
|
||||||
public class CppScriptProxy : CppProxy
|
public class CppScriptProxy : CppProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -98,6 +99,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Context proxy object for C++ Json Asset files.
|
/// Context proxy object for C++ Json Asset files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||||
|
[ContentContextMenu("New/C++/C++ Function Library")]
|
||||||
public class CppStaticClassProxy : CppProxy
|
public class CppStaticClassProxy : CppProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -115,6 +117,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Context proxy object for C++ Json Asset files.
|
/// Context proxy object for C++ Json Asset files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
/// <seealso cref="FlaxEditor.Content.CSharpScriptProxy" />
|
||||||
|
[ContentContextMenu("New/C++/C++ Json Asset")]
|
||||||
public class CppAssetProxy : CppProxy
|
public class CppAssetProxy : CppProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Cube Texture";
|
public override string Name => "Cube Texture";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Texture";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ namespace FlaxEditor.Content
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Font";
|
public override string Name => "Font";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Font";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="GameplayGlobals"/> asset proxy object.
|
/// A <see cref="GameplayGlobals"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Gameplay Globals")]
|
||||||
public class GameplayGlobalsProxy : BinaryAssetProxy
|
public class GameplayGlobalsProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Gameplay Globals";
|
public override string Name => "Gameplay Globals";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Globals";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "IES Profile";
|
public override string Name => "IES Profile";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Lighting";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Json assets proxy.
|
/// Json assets proxy.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||||
|
[ContentContextMenu("New/Json Asset")]
|
||||||
public abstract class JsonAssetProxy : JsonAssetBaseProxy
|
public abstract class JsonAssetProxy : JsonAssetBaseProxy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,9 +32,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Json Asset";
|
public override string Name => "Json Asset";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Json Asset";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string FileExtension => Extension;
|
public override string FileExtension => Extension;
|
||||||
@@ -168,20 +166,6 @@ namespace FlaxEditor.Content
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name { get; } = Utilities.Utils.GetPropertyNameUI(typeof(T).Name);
|
public override string Name { get; } = Utilities.Utils.GetPropertyNameUI(typeof(T).Name);
|
||||||
|
|
||||||
private string _categoryName;
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => _categoryName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the category name
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">This is the category name</param>
|
|
||||||
public void SetCategoryName(string name)
|
|
||||||
{
|
|
||||||
_categoryName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanCreate(ContentFolder targetLocation)
|
public override bool CanCreate(ContentFolder targetLocation)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="MaterialFunction"/> asset proxy object.
|
/// A <see cref="MaterialFunction"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Material/Material Function")]
|
||||||
public class MaterialFunctionProxy : BinaryAssetProxy
|
public class MaterialFunctionProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Material Function";
|
public override string Name => "Material Function";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Material";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -14,15 +14,13 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="MaterialInstance"/> asset proxy object.
|
/// A <see cref="MaterialInstance"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Material/Material Instance")]
|
||||||
public class MaterialInstanceProxy : BinaryAssetProxy
|
public class MaterialInstanceProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
private MaterialPreview _preview;
|
private MaterialPreview _preview;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Material Instance";
|
public override string Name => "Material Instance";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Material";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -15,15 +15,13 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="Material"/> asset proxy object.
|
/// A <see cref="Material"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Material/Material")]
|
||||||
public class MaterialProxy : BinaryAssetProxy
|
public class MaterialProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
private MaterialPreview _preview;
|
private MaterialPreview _preview;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Material";
|
public override string Name => "Material";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Material";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Model";
|
public override string Name => "Model";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Model";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="ParticleEmitterFunction"/> asset proxy object.
|
/// A <see cref="ParticleEmitterFunction"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Particles/Particle Emitter Function")]
|
||||||
public class ParticleEmitterFunctionProxy : BinaryAssetProxy
|
public class ParticleEmitterFunctionProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Particle Emitter Function";
|
public override string Name => "Particle Emitter Function";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Particles";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="ParticleEmitter"/> asset proxy object.
|
/// A <see cref="ParticleEmitter"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Particles/Particle Emitter")]
|
||||||
public class ParticleEmitterProxy : BinaryAssetProxy
|
public class ParticleEmitterProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
private ParticleEmitterPreview _preview;
|
private ParticleEmitterPreview _preview;
|
||||||
@@ -22,9 +23,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Particle Emitter";
|
public override string Name => "Particle Emitter";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Particles";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="ParticleSystem"/> asset proxy object.
|
/// A <see cref="ParticleSystem"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Particles/Particle System")]
|
||||||
public class ParticleSystemProxy : BinaryAssetProxy
|
public class ParticleSystemProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
private ParticleSystemPreview _preview;
|
private ParticleSystemPreview _preview;
|
||||||
@@ -46,9 +47,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Particle System";
|
public override string Name => "Particle System";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Particles";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Content proxy for <see cref="PrefabItem"/>.
|
/// Content proxy for <see cref="PrefabItem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||||
|
[ContentContextMenu("New/Prefab")]
|
||||||
public sealed class PrefabProxy : JsonAssetBaseProxy
|
public sealed class PrefabProxy : JsonAssetBaseProxy
|
||||||
{
|
{
|
||||||
private PrefabPreview _preview;
|
private PrefabPreview _preview;
|
||||||
@@ -31,9 +32,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Prefab";
|
public override string Name => "Prefab";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Prefab";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string FileExtension => Extension;
|
public override string FileExtension => Extension;
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ namespace FlaxEditor.Content
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Previews Cache";
|
public override string Name => "Previews Cache";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Previews Cache";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ namespace FlaxEditor.Content
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Scene Animation";
|
public override string Name => "Scene Animation";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Animation";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Content proxy for <see cref="SceneItem"/>.
|
/// Content proxy for <see cref="SceneItem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
/// <seealso cref="FlaxEditor.Content.JsonAssetBaseProxy" />
|
||||||
|
[ContentContextMenu("New/Scene")]
|
||||||
public sealed class SceneProxy : JsonAssetBaseProxy
|
public sealed class SceneProxy : JsonAssetBaseProxy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -19,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Scene";
|
public override string Name => "Scene";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Scene";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string FileExtension => Extension;
|
public override string FileExtension => Extension;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace FlaxEditor.Content
|
|||||||
/// Content proxy for json settings assets (e.g <see cref="GameSettings"/> or <see cref="TimeSettings"/>).
|
/// Content proxy for json settings assets (e.g <see cref="GameSettings"/> or <see cref="TimeSettings"/>).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.JsonAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.JsonAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Settings")]
|
||||||
public class SettingsProxy : JsonAssetProxy
|
public class SettingsProxy : JsonAssetProxy
|
||||||
{
|
{
|
||||||
private readonly Type _type;
|
private readonly Type _type;
|
||||||
@@ -20,9 +21,6 @@ namespace FlaxEditor.Content
|
|||||||
/// Gets the settings type.
|
/// Gets the settings type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type Type => _type;
|
public Type Type => _type;
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Settings";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SettingsProxy"/> class.
|
/// Initializes a new instance of the <see cref="SettingsProxy"/> class.
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ namespace FlaxEditor.Content
|
|||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Shader";
|
public override string Name => "Shader";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Shader";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="SkeletonMask"/> asset proxy object.
|
/// A <see cref="SkeletonMask"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Animation/Skeleton Mask")]
|
||||||
public class SkeletonMaskProxy : BinaryAssetProxy
|
public class SkeletonMaskProxy : BinaryAssetProxy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Skeleton Mask";
|
public override string Name => "Skeleton Mask";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Animation";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Skinned Model";
|
public override string Name => "Skinned Model";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Model";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Sprite Atlas";
|
public override string Name => "Sprite Atlas";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Sprites";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Texture";
|
public override string Name => "Texture";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Texture";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool CanReimport(ContentItem item)
|
public override bool CanReimport(ContentItem item)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace FlaxEditor.Content
|
|||||||
/// A <see cref="VisualScript"/> asset proxy object.
|
/// A <see cref="VisualScript"/> asset proxy object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
/// <seealso cref="FlaxEditor.Content.BinaryAssetProxy" />
|
||||||
|
[ContentContextMenu("New/Visual Script")]
|
||||||
public class VisualScriptProxy : BinaryAssetProxy, IScriptTypesContainer
|
public class VisualScriptProxy : BinaryAssetProxy, IScriptTypesContainer
|
||||||
{
|
{
|
||||||
internal VisualScriptProxy()
|
internal VisualScriptProxy()
|
||||||
@@ -24,9 +25,6 @@ namespace FlaxEditor.Content
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string Name => "Visual Script";
|
public override string Name => "Visual Script";
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override string CategoryName => "Scripting";
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override EditorWindow Open(Editor editor, ContentItem item)
|
public override EditorWindow Open(Editor editor, ContentItem item)
|
||||||
|
|||||||
@@ -927,9 +927,7 @@ namespace FlaxEditor.Modules
|
|||||||
Proxy.Add(new VisualScriptProxy());
|
Proxy.Add(new VisualScriptProxy());
|
||||||
Proxy.Add(new LocalizedStringTableProxy());
|
Proxy.Add(new LocalizedStringTableProxy());
|
||||||
Proxy.Add(new FileProxy());
|
Proxy.Add(new FileProxy());
|
||||||
var pm = new SpawnableJsonAssetProxy<PhysicalMaterial>();
|
Proxy.Add(new SpawnableJsonAssetProxy<PhysicalMaterial>());
|
||||||
pm.SetCategoryName("Physics");
|
|
||||||
Proxy.Add(pm);
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
Proxy.Add(new SettingsProxy(typeof(GameSettings), Editor.Instance.Icons.GameSettings128));
|
Proxy.Add(new SettingsProxy(typeof(GameSettings), Editor.Instance.Icons.GameSettings128));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.CodeDom;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FlaxEditor.Content;
|
using FlaxEditor.Content;
|
||||||
@@ -152,64 +153,78 @@ namespace FlaxEditor.Windows
|
|||||||
{
|
{
|
||||||
cm.AddButton("New folder", NewFolder);
|
cm.AddButton("New folder", NewFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// categorize the asset proxies according to their category name
|
// loop through each proxy and user defined json type and add them to the context menu
|
||||||
Dictionary<string, List<AssetProxy>> categorizedProxyList = new Dictionary<string, List<AssetProxy>>();
|
foreach (var type in Editor.CodeEditing.All.Get())
|
||||||
for (int i = 0; i < Editor.ContentDatabase.Proxy.Count; i++)
|
|
||||||
{
|
{
|
||||||
var p = Editor.ContentDatabase.Proxy[i];
|
if (type.IsAbstract || !type.HasAttribute(typeof(ContentContextMenuAttribute), true))
|
||||||
|
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);
|
||||||
|
dynamic obj = instance;
|
||||||
|
p = obj as AssetProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// create menus
|
||||||
if (p.CanCreate(folder))
|
if (p.CanCreate(folder))
|
||||||
{
|
{
|
||||||
if (p is AssetProxy ap)
|
var splitPath = attribute.Path.Split('/');
|
||||||
|
ContextMenuChildMenu childCM = null;
|
||||||
|
bool mainCM = true;
|
||||||
|
for (int i = 0; i < splitPath?.Length; i++)
|
||||||
{
|
{
|
||||||
if (categorizedProxyList.ContainsKey(ap.CategoryName))
|
if (i == splitPath.Length - 1)
|
||||||
{
|
{
|
||||||
categorizedProxyList.TryGetValue(ap.CategoryName, out var apList);
|
if (mainCM)
|
||||||
apList?.Add(ap);
|
{
|
||||||
|
cm.AddButton(splitPath[i].Trim(), () => NewItem(p));
|
||||||
|
mainCM = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
childCM?.ContextMenu.AddButton(splitPath[i].Trim(), () => NewItem(p));
|
||||||
|
childCM.ContextMenu.AutoSort = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
categorizedProxyList.Add(ap.CategoryName, new List<AssetProxy>() {ap});
|
if (mainCM)
|
||||||
|
{
|
||||||
|
childCM = cm.GetOrAddChildMenu(splitPath[i].Trim());
|
||||||
|
mainCM = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
childCM = childCM?.ContextMenu.GetOrAddChildMenu(splitPath[i].Trim());
|
||||||
|
}
|
||||||
|
childCM.ContextMenu.AutoSort = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
var p = Editor.ContentDatabase.Proxy[i];
|
|
||||||
if (p.CanCreate(folder))
|
|
||||||
{
|
|
||||||
if (p is AssetProxy ap && categorizedProxyList.TryGetValue(ap.CategoryName, out var apList))
|
|
||||||
{
|
|
||||||
if (apList.Contains(ap))
|
|
||||||
{
|
|
||||||
if (apList.Count > 1)
|
|
||||||
{
|
|
||||||
var childMenu = c.ContextMenu.GetOrAddChildMenu(ap.CategoryName);
|
|
||||||
childMenu.ContextMenu.AutoSort = true;
|
|
||||||
childMenu.ContextMenu.AddButton(p.Name, () => NewItem(p));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c.ContextMenu.AddButton(p.Name, () => NewItem(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c.ContextMenu.AddButton(p.Name, () => NewItem(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
newItems++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.Enabled = newItems > 0;
|
|
||||||
|
|
||||||
if (folder.CanHaveAssets)
|
if (folder.CanHaveAssets)
|
||||||
{
|
{
|
||||||
cm.AddButton("Import file", () =>
|
cm.AddButton("Import file", () =>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
|
/// Physical materials are used to define the response of a physical object when interacting dynamically with the world.
|
||||||
/// </summary>
|
/// </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();
|
API_AUTO_SERIALIZATION();
|
||||||
DECLARE_SCRIPTING_TYPE_MINIMAL(PhysicalMaterial);
|
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