ResourceFormatLoader
Custom resource-format read handler.
Implement a C# subclass with _GetRecognizedExtensions, _HandlesType, _GetResourceType and _Load. Register its instance using ResourceLoader.AddResourceFormatLoader before the first Load and unregister before Dispose. Construction alone does not register the handler.
Underscore methods are engine callbacks. Documented default checks refer to native dispatch when no override exists. Use ResourceLoader.Load for ordinary reads rather than calling a callback directly.
_Load returns a Resource or an integer Error inside a Variant. Path recognition selects a handler without validating contents. Dependencies, UIDs, thread safety and cache modes need separate handling when the format uses them.
custom resource format: complete executable C# example.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ResourceFormatLoaderConstructor
public ResourceFormatLoader();Creates an unregistered handler. Implement a subclass with callbacks and add its instance to ResourceLoader before the first read.
Methods11
_Existsbool
public virtual bool _Exists(string path);Checks resource existence. Without an override the native handler uses FileAccess. File presence does not establish valid contents or a successful later read.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
booltrue when the handler considers the resource present; not a guarantee of a successful read.
_GetClassesUsedstring[]
public virtual string[] _GetClassesUsed(string path);Reports class names used by file contents. Without an override the native handler adds the nonempty base resource-type result. Return names, not object instances.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
string[]Array of class-name strings; an empty array when no classes are reported.
_GetDependenciesstring[]
public virtual string[] _GetDependencies(string path, bool addTypes);Lists external file references. Each entry is a path or uid::type::fallback_path; the type section is empty when addTypes=false. Trailing empty sections are omitted. Listing neither loads dependencies nor rewrites the file.
| Name | Type | Default |
|---|---|---|
path | string | — |
addTypes | bool | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
addTypestrue adds a base type name after the first ::. Resource suits a script resource without a separate native type.
string[]Dependency-entry array. With UID and fallback path but no type: uid://...::::asset://data/item.rdata.
_GetRecognizedExtensionsstring[]
public virtual string[] _GetRecognizedExtensions();Lists file extensions the handler can read, such as rfnote without a dot. This informs loader selection rather than validating each file’s contents.
string[]Array of extensions without dots; an empty array provides no extensions for default selection.
_GetResourceScriptClassstring
public virtual string _GetResourceScriptClass(string path);Reports the resource’s named script class separately from its built-in base type. It neither registers the class nor creates an object.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
stringNamed script-class name, or an empty string if no such name exists or the format does not report it.
_GetResourceTypestring
public virtual string _GetResourceType(string path);Determines the built-in resource type for a path. Resource is valid for a supported custom C# resource. A C# class name does not by itself become a native ClassDB type.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
stringSupported built-in type name, or an empty string when the path is not recognized.
_GetResourceUidlong
public virtual long _GetResourceUid(string path);Reads a persistent UID from a custom format. Overriding enables custom UID support; do not add an always--1 stub when the standard .uid mechanism is intended. Without an override the native handler reads path + .uid; creating that file belongs to the editor workflow, not this read.
| Name | Type | Default |
|---|---|---|
path | string | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
longNumeric UID, or -1 when no valid identifier exists. This is not a file path.
_HandlesTypebool
public virtual bool _HandlesType(StringName type);Reports support for a base type. Default native path recognition uses this callback for a nonempty type hint. Without an override no type support is declared.
| Name | Type | Default |
|---|---|---|
type | StringName | — |
typeBuilt-in type hint, such as Resource. Explicitly handle every supported type.
booltrue for a supported type; false allows this handler to be skipped for that type hint.
_LoadVariant
public virtual Variant _Load(string path, string originalPath, bool useSubThreads, int cacheMode);Reads and validates the file after handler selection. Return a Resource in a Variant on success, or an integer Error on failure. Error.Ok in place of an object is not success: any integer is treated as an error code and produces no resource. Bound sizes before allocation.
| Name | Type | Default |
|---|---|---|
path | string | — |
originalPath | string | — |
useSubThreads | bool | — |
cacheMode | int | — |
pathActual read path after resource routing. Do not unconditionally substitute originalPath.
originalPathOriginal logical path before remapping/import. It can differ from path; this is resource context rather than an instruction to read the source asset.
useSubThreadsPermission to use additional threads. true neither spawns them for your code nor makes the handler thread-safe.
cacheModeNumeric ResourceFormatLoader.CacheMode value. Honor its intended dependency-loading and format-data update behavior.
VariantVariant containing a Resource on success or an integer Error on failure. An empty Variant neither creates a resource nor supplies a useful error code.
_RecognizePathbool
public virtual bool _RecognizePath(string path, StringName type);Determines whether the handler suits a path and type hint. Without an override the native implementation matches extension suffixes case-insensitively and uses _HandlesType, not _GetResourceType, for a nonempty type. An override replaces that check.
| Name | Type | Default |
|---|---|---|
path | string | — |
type | StringName | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
typeOptional built-in type hint, such as Resource. An empty string imposes no type restriction in default path recognition.
booltrue when the path suits the format. This selects a handler rather than validating contents or permissions.
_RenameDependenciesError
public virtual Error _RenameDependencies(string path, Reckfell.Collections.Dictionary renames);Rewrites external references in the file using the mapping and persists the result. Mutating only the supplied Dictionary is insufficient. Without an override the native handler returns Ok without rewriting anything; that code alone does not prove references were updated.
| Name | Type | Default |
|---|---|---|
path | string | — |
renames | Reckfell.Collections.Dictionary | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
renamesDictionary of string paths: old path to new path. Rewrite references in the file; the mapping itself does not rename the file.
ErrorError.Ok after successfully completing the supported operation, or a specific Error on failure.
ResourceFormatLoader.CacheMode
| Value | Description |
|---|---|
Ignore = 0 | Neither the main resource (the one requested to be loaded) nor any of its subresources are retrieved from cache nor stored into it. Dependencies (external resources) are loaded with |
IgnoreDeep = 3 | Like |
Replace = 2 | Like |
ReplaceDeep = 4 | Like |
Reuse = 1 | The main resource (the one requested to be loaded), its subresources, and its dependencies (external resources) are retrieved from cache if present, instead of loaded. Those not cached are loaded and then stored into the cache. The same rules are propagated recursively down the tree of dependencies (external resources). |