Skip to main content

Overview

The AssetDefinition class describes editor-related functionality for a specific asset type. Plugins can derive from this class to customize asset icons, override editors, and define import/export methods.

Registration

Register your asset definition using the RegisterAssetDefinitionAttribute in your plugin’s AssemblyInfo.cs:
using Frosty.Core.Attributes;

[assembly: RegisterAssetDefinition("MeshAsset", typeof(MeshAssetDefinition))]
The definition will be associated with the specified type and all derived types in the game’s type system.

Constructor

AssetDefinition

public AssetDefinition()
Initializes a new instance of the AssetDefinition class.

Virtual Methods

GetEditor

public virtual FrostyAssetEditor GetEditor(ILogger logger)
Returns a custom editor used to edit the asset. Must inherit from FrostyAssetEditor.
logger
ILogger
required
The logging interface to use in the editor
return
FrostyAssetEditor
A custom asset editor instance, or null to use the default editor
public override FrostyAssetEditor GetEditor(ILogger logger)
{
    return new MeshAssetEditor(logger);
}

GetIcon

public virtual ImageSource GetIcon()
public virtual ImageSource GetIcon(AssetEntry entry, double width = double.PositiveInfinity, double height = double.PositiveInfinity)
Returns an icon for the asset type or a specific asset entry.
entry
AssetEntry
The asset entry to generate an icon for
width
double
default:"PositiveInfinity"
Suggested width for the icon
height
double
default:"PositiveInfinity"
Suggested height for the icon
return
ImageSource
An ImageSource representing the icon, or null for default
public override ImageSource GetIcon()
{
    return new BitmapImage(new Uri("pack://application:,,,/MeshPlugin;component/Images/MeshIcon.png"));
}

GetSupportedExportTypes

public virtual void GetSupportedExportTypes(List<AssetExportType> exportTypes)
Provides a list of valid export file types for the asset.
exportTypes
List<AssetExportType>
required
List to populate with supported export types
public override void GetSupportedExportTypes(List<AssetExportType> exportTypes)
{
    exportTypes.Add(new AssetExportType("fbx", "Autodesk FBX"));
    exportTypes.Add(new AssetExportType("obj", "Wavefront OBJ"));
    exportTypes.Add(new AssetExportType("dae", "COLLADA DAE"));
    
    // Include default types
    base.GetSupportedExportTypes(exportTypes);
}
Default export types (if not overridden):
  • bin: Binary File
  • xml: XML File

GetSupportedImportTypes

public virtual void GetSupportedImportTypes(List<AssetImportType> importTypes)
Provides a list of valid import file types for the asset.
importTypes
List<AssetImportType>
required
List to populate with supported import types
public override void GetSupportedImportTypes(List<AssetImportType> importTypes)
{
    importTypes.Add(new AssetImportType("fbx", "Autodesk FBX"));
    importTypes.Add(new AssetImportType("obj", "Wavefront OBJ"));
    importTypes.Add(new AssetImportType("dae", "COLLADA DAE"));
    
    // Include default types
    base.GetSupportedImportTypes(importTypes);
}
Default import types (if not overridden):
  • bin: Binary File (Data Only)
  • bin: Binary File

Export

public virtual bool Export(EbxAssetEntry entry, string path, string filterType)
Performs the actual export of the asset.
entry
EbxAssetEntry
required
The asset entry to export
path
string
required
The full path and filename to export to
filterType
string
required
The file extension of the chosen export type
return
bool
True if export was successful, false otherwise
public override bool Export(EbxAssetEntry entry, string path, string filterType)
{
    EbxAsset asset = App.AssetManager.GetEbx(entry);
    dynamic meshAsset = asset.RootObject;
    
    if (filterType == "fbx")
    {
        return ExportToFbx(meshAsset, path);
    }
    else if (filterType == "obj")
    {
        return ExportToObj(meshAsset, path);
    }
    
    // Fall back to default export
    return base.Export(entry, path, filterType);
}

private bool ExportToFbx(dynamic meshAsset, string path)
{
    try
    {
        // Export logic here
        using (var writer = new FbxWriter(path))
        {
            writer.WriteMesh(meshAsset);
        }
        return true;
    }
    catch (Exception ex)
    {
        App.Logger.LogError($"Failed to export FBX: {ex.Message}");
        return false;
    }
}

Import

public virtual bool Import(EbxAssetEntry entry, string path, AssetImportType filterType)
Performs the actual import of data into the asset.
entry
EbxAssetEntry
required
The asset entry to import data into
path
string
required
The full path and filename to import from
filterType
AssetImportType
required
The chosen import type containing extension and description
return
bool
True if import was successful, false otherwise
public override bool Import(EbxAssetEntry entry, string path, AssetImportType filterType)
{
    if (filterType.Extension == "fbx")
    {
        return ImportFromFbx(entry, path);
    }
    else if (filterType.Extension == "obj")
    {
        return ImportFromObj(entry, path);
    }
    
    // Fall back to default import
    return base.Import(entry, path, filterType);
}

private bool ImportFromFbx(EbxAssetEntry entry, string path)
{
    try
    {
        EbxAsset asset = App.AssetManager.GetEbx(entry);
        dynamic meshAsset = asset.RootObject;
        
        using (var reader = new FbxReader(path))
        {
            // Read mesh data and update asset
            reader.ReadMesh(meshAsset);
        }
        
        // Mark asset as modified
        App.AssetManager.ModifyEbx(entry.Name, asset);
        return true;
    }
    catch (Exception ex)
    {
        App.Logger.LogError($"Failed to import FBX: {ex.Message}");
        return false;
    }
}

Helper Structures

AssetExportType

public struct AssetExportType
{
    public string Extension { get; }
    public string Description { get; }
    public string FilterString { get; }
    
    public AssetExportType(string ext, string desc)
}
Represents an export file type.
ext
string
File extension without the dot (e.g., “fbx”)
desc
string
Human-readable description (e.g., “Autodesk FBX”)

AssetImportType

public struct AssetImportType
{
    public string Extension { get; }
    public string Description { get; }
    public string FilterString { get; }
    
    public AssetImportType(string ext, string desc)
}
Represents an import file type.
ext
string
File extension without the dot (e.g., “fbx”)
desc
string
Human-readable description (e.g., “Autodesk FBX”)

Complete Example

using Frosty.Core;
using Frosty.Core.Controls;
using FrostySdk;
using FrostySdk.Interfaces;
using System.Collections.Generic;
using System.Windows.Media;

public class MeshAssetDefinition : AssetDefinition
{
    public override FrostyAssetEditor GetEditor(ILogger logger)
    {
        return new MeshAssetEditor(logger);
    }
    
    public override ImageSource GetIcon()
    {
        return new BitmapImage(new Uri("pack://application:,,,/MeshPlugin;component/Images/MeshIcon.png"));
    }
    
    public override void GetSupportedExportTypes(List<AssetExportType> exportTypes)
    {
        exportTypes.Add(new AssetExportType("fbx", "Autodesk FBX"));
        exportTypes.Add(new AssetExportType("obj", "Wavefront OBJ"));
        base.GetSupportedExportTypes(exportTypes);
    }
    
    public override void GetSupportedImportTypes(List<AssetImportType> importTypes)
    {
        importTypes.Add(new AssetImportType("fbx", "Autodesk FBX"));
        importTypes.Add(new AssetImportType("obj", "Wavefront OBJ"));
        base.GetSupportedImportTypes(importTypes);
    }
    
    public override bool Export(EbxAssetEntry entry, string path, string filterType)
    {
        if (filterType == "fbx")
            return ExportToFbx(entry, path);
        if (filterType == "obj")
            return ExportToObj(entry, path);
            
        return base.Export(entry, path, filterType);
    }
    
    public override bool Import(EbxAssetEntry entry, string path, AssetImportType filterType)
    {
        if (filterType.Extension == "fbx")
            return ImportFromFbx(entry, path);
        if (filterType.Extension == "obj")
            return ImportFromObj(entry, path);
            
        return base.Import(entry, path, filterType);
    }
    
    private bool ExportToFbx(EbxAssetEntry entry, string path)
    {
        // Implementation
        return true;
    }
    
    private bool ExportToObj(EbxAssetEntry entry, string path)
    {
        // Implementation
        return true;
    }
    
    private bool ImportFromFbx(EbxAssetEntry entry, string path)
    {
        // Implementation
        return true;
    }
    
    private bool ImportFromObj(EbxAssetEntry entry, string path)
    {
        // Implementation
        return true;
    }
}

See Also

Build docs developers (and LLMs) love