codeAPI Reference
s&box ResourceSelectAttribute: Resource picker configuration
ResourceSelectAttribute API Reference
ResourceSelectAttribute is used to configure resource selection UI for properties in the inspector.
Type Signature
CSHARP
namespace Sandbox.UI;
public sealed class ResourceSelectAttribute : System.Attribute
{
public string Extension { get; set; }
public bool AllowPackages { get; set; }
}Properties
- string Extension { get; set; } - The file extension filter for the resource picker (e.g., "vmdl", "vmat", "prefab").
- bool AllowPackages { get; set; } - Whether to allow selecting resources from packages.
Usage
Apply ResourceSelectAttribute to a property to configure the resource picker UI:
CSHARP
public class MyComponent : Component
{
[Property, ResourceSelect(Extension = "vmdl", AllowPackages = true)]
public Model Model { get; set; }
[Property, ResourceSelect(Extension = "vmat")]
public Material Material { get; set; }
[Property, ResourceSelect(Extension = "prefab", AllowPackages = false)]
public PrefabFile Prefab { get; set; }
}Notes
- Used by the inspector to show a resource picker button for the property
- Extension filters the resource picker to show only matching file types
- AllowPackages controls whether package resources can be selected
- Common extensions: "vmdl" (models), "vmat" (materials), "prefab" (prefabs), "vmdl_c" (compiled models)
- If AllowPackages is false, only local project resources are shown
Was this helpful?