mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 21:01:48 +00:00
Better asset processor selection, process subassets
This commit is contained in:
@@ -8,7 +8,7 @@ namespace GlitchyEditor.Assets.Importers;
|
||||
abstract class Config
|
||||
{
|
||||
[BonIgnore]
|
||||
protected bool _changed;
|
||||
protected bool _changed = true;
|
||||
|
||||
public bool Changed => _changed;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ interface IAssetImporter
|
||||
/// The type that ImportedResource returns.
|
||||
static Type ProcessedAssetType { get; }
|
||||
|
||||
Result<ImportedResource> Import(StringView fullFileName, AssetIdentifier assetIdentifier, AssetImporterConfig config);
|
||||
Result<ImportedResource> Import(StringView fullFileName, AssetIdentifier assetIdentifier, AssetConfig config);
|
||||
}
|
||||
|
||||
interface IAssetProcessor
|
||||
@@ -25,7 +25,7 @@ interface IAssetProcessor
|
||||
/// The asset type that this processor can process.
|
||||
static Type ProcessedAssetType { get; }
|
||||
|
||||
Result<void> Process(ImportedResource importedResource, AssetProcessorConfig config, List<ProcessedResource> outProcessedResources);
|
||||
Result<void> Process(ImportedResource importedResource, AssetConfig config, List<ProcessedResource> outProcessedResources);
|
||||
}
|
||||
|
||||
interface IAssetExporter
|
||||
@@ -35,5 +35,5 @@ interface IAssetExporter
|
||||
/// The asset type that this exporter can export.
|
||||
static AssetType ExportedAssetType { get; }
|
||||
|
||||
Result<void> Export(Stream stream, ProcessedResource processedObject, AssetExporterConfig config);
|
||||
Result<void> Export(Stream stream, ProcessedResource processedObject, AssetConfig config);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using GlitchyEngine.Content;
|
||||
using GlitchyEngine;
|
||||
using GlitchyEngine.Renderer;
|
||||
using GlitchyEngine.Math;
|
||||
//using System.Threading;
|
||||
using GlitchyEditor.Assets.Processors;
|
||||
using ImGui;
|
||||
|
||||
@@ -53,22 +54,29 @@ class TextureImporterConfig : AssetImporterConfig
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TextureImporter : IAssetImporter
|
||||
{
|
||||
private static readonly List<StringView> _fileExtensions = new .(){".png", ".dds"} ~ delete _;
|
||||
|
||||
public static List<StringView> FileExtensions => _fileExtensions;
|
||||
|
||||
public static Type ProcessedAssetType => typeof(ImportedTexture);
|
||||
|
||||
public AssetImporterConfig CreateDefaultConfig()
|
||||
{
|
||||
return new TextureImporterConfig();
|
||||
}
|
||||
|
||||
public Result<ImportedResource> Import(StringView fullFileName, AssetIdentifier assetIdentifier, AssetImporterConfig config)
|
||||
public Result<ImportedResource> Import(StringView fullFileName, AssetIdentifier assetIdentifier, AssetConfig config)
|
||||
{
|
||||
//Thread.Sleep(1000);
|
||||
|
||||
Log.EngineLogger.AssertDebug(config is TextureImporterConfig);
|
||||
TextureImporterConfig textureImporterConfig = config.ImporterConfig as TextureImporterConfig;
|
||||
|
||||
if (textureImporterConfig == null)
|
||||
{
|
||||
config.ImporterConfig = textureImporterConfig = new TextureImporterConfig();
|
||||
}
|
||||
|
||||
ImportedTexture importedData = new ImportedTexture(new AssetIdentifier(assetIdentifier.FullIdentifier));
|
||||
|
||||
@@ -76,7 +84,7 @@ class TextureImporter : IAssetImporter
|
||||
FileStream stream = scope FileStream();
|
||||
Try!(stream.Open(fullFileName, .Read, .Read));
|
||||
|
||||
Result<void> importResult = ImportTexture(stream, importedData, (TextureImporterConfig)config);
|
||||
Result<void> importResult = ImportTexture(stream, importedData, (TextureImporterConfig)textureImporterConfig);
|
||||
|
||||
stream.Close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user