Refactor Editor.CreateAsset to use named tags for better extensibility with custom assets in plugins

This commit is contained in:
Wojtek Figat
2024-02-18 11:22:35 +01:00
parent d76b5234c5
commit 636b2c91cc
18 changed files with 79 additions and 97 deletions

View File

@@ -81,7 +81,7 @@ namespace FlaxEditor.Content.Create
switch (_options.Template)
{
case Templates.Empty:
return Editor.CreateAsset(Editor.NewAssetType.ParticleEmitter, ResultUrl);
return Editor.CreateAsset("ParticleEmitter", ResultUrl);
case Templates.ConstantBurst:
templateName = "Constant Burst";
break;

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.AnimationGraphFunction, outputPath))
if (Editor.CreateAsset("AnimationGraphFunction", outputPath))
throw new Exception("Failed to create new asset.");
}
}

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.AnimationGraph, outputPath))
if (Editor.CreateAsset("AnimationGraph", outputPath))
throw new Exception("Failed to create new asset.");
}
}

View File

@@ -47,7 +47,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.Animation, outputPath))
if (Editor.CreateAsset("Animation", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -47,7 +47,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.BehaviorTree, outputPath))
if (Editor.CreateAsset("BehaviorTree", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -71,7 +71,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.CollisionData, outputPath))
if (Editor.CreateAsset("CollisionData", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.MaterialFunction, outputPath))
if (Editor.CreateAsset("MaterialFunction", outputPath))
throw new Exception("Failed to create new asset.");
}
}

View File

@@ -43,7 +43,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.MaterialInstance, outputPath))
if (Editor.CreateAsset("MaterialInstance", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -44,7 +44,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.Material, outputPath))
if (Editor.CreateAsset("Material", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.ParticleEmitterFunction, outputPath))
if (Editor.CreateAsset("ParticleEmitterFunction", outputPath))
throw new Exception("Failed to create new asset.");
}
}

View File

@@ -75,7 +75,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.ParticleSystem, outputPath))
if (Editor.CreateAsset("ParticleSystem", outputPath))
throw new Exception("Failed to create new asset.");
}

View File

@@ -69,7 +69,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.SceneAnimation, outputPath))
if (Editor.CreateAsset("SceneAnimation", outputPath))
throw new Exception("Failed to create new asset.");
}
}

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.Content
/// <inheritdoc />
public override void Create(string outputPath, object arg)
{
if (Editor.CreateAsset(Editor.NewAssetType.SkeletonMask, outputPath))
if (Editor.CreateAsset("SkeletonMask", outputPath))
throw new Exception("Failed to create new asset.");
}
}