Editor model and attribute used to restrict asset picker to a single file extension and provide a material path property. AssetPathTypeAttribute inherits AssetPathAttribute and returns a fixed extension; DefaultMaterialModel exposes a serialized Material string with that attribute so editor will show a .vmat picker.
using System;
using System.ComponentModel;
namespace ModelPro.Editor;
/// <summary>
/// A concrete <see cref="AssetPathAttribute"/> that restricts picking to a single
/// asset type extension. Used so the material field only accepts .vmat files.
/// </summary>
[AttributeUsage( AttributeTargets.Property )]
public class AssetPathTypeAttribute : AssetPathAttribute
{
readonly string _extension;
public AssetPathTypeAttribute( string extension )
{
_extension = extension;
}
public override string AssetTypeExtension => _extension;
}
/// <summary>
/// A tiny serialized object used to render a material picker control. The
/// [AssetPathType("vmat")] attribute makes the editor use its material picker,
/// so only .vmat assets can be selected.
/// </summary>
public class DefaultMaterialModel
{
/// <summary>The selected default material path, e.g. "materials/default.vmat".</summary>
[AssetPathType( "vmat" )]
public string Material { get; set; } = "";
}