ResourceFormatSaver
Custom resource-format write handler.
Implement a C# subclass with _Recognize, _GetRecognizedExtensions and _Save. Register its instance using ResourceSaver.AddResourceFormatSaver before Save and unregister before Dispose. Declaring the class does not replace this lifecycle.
ResourceSaver selects a handler by object and path. _Save must write data and return a truthful Error. Flags, dependencies, UIDs, atomic replacement and backups are not implemented for you.
Underscore methods are intended for overriding. Call ResourceSaver.Save for ordinary saves. Documented absent-override values refer to the native handler.
custom resource format: complete executable C# example.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ResourceFormatSaverConstructor
public ResourceFormatSaver();Creates an unregistered save handler. Implement a subclass and register its instance with ResourceSaver before Save.
Methods5
_GetRecognizedExtensionsstring[]
public virtual string[] _GetRecognizedExtensions(Resource resource);Lists save extensions for the specific object. Keep the result consistent with _Recognize and do not advertise extensions for an unsupported type.
| Name | Type | Default |
|---|---|---|
resource | Resource | — |
resourceObject to inspect or save. Check the supported concrete type, not just Resource inheritance.
string[]Array of extensions without dots; an empty array provides no extensions for default selection.
_Recognizebool
public virtual bool _Recognize(Resource resource);Checks support for the object by its type and format capabilities. _RecognizePath checks the path separately. Without an override the native handler returns false.
| Name | Type | Default |
|---|---|---|
resource | Resource | — |
resourceObject to inspect or save. Check the supported concrete type, not just Resource inheritance.
booltrue for a supported object. This does not establish a successful write or file accessibility.
_RecognizePathbool
public virtual bool _RecognizePath(Resource resource, string path);Checks support for the object’s save path. Without an override the native implementation case-insensitively matches its extension against _GetRecognizedExtensions(resource). An override replaces this check; selecting a format does not open the file.
| Name | Type | Default |
|---|---|---|
resource | Resource | — |
path | string | — |
resourceObject to inspect or save. Check the supported concrete type, not just Resource inheritance.
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
booltrue when the path suits the format. This selects a handler rather than validating contents or permissions.
_SaveError
public virtual Error _Save(Resource resource, string path, uint flags);Writes the object in the custom format and returns Error. Check opening, serialization and writing; do not return Ok after failure. Flags, atomic replacement and backups are not automatically implemented.
| Name | Type | Default |
|---|---|---|
resource | Resource | — |
path | string | — |
flags | uint | — |
resourceObject to inspect or save. Check the supported concrete type, not just Resource inheritance.
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
flagsResourceSaver.SaverFlags bitmask. Implement flags applicable to the format or explicitly reject unsupported ones.
ErrorError.Ok after a successful write, or a failure code. Without an override the native handler returns MethodNotFound.
_SetUidError
public virtual Error _SetUid(string path, long uid);Updates a UID stored in the custom-format file. Separate from _Save and not a path rename. Without an override the native handler returns FileUnrecognized.
| Name | Type | Default |
|---|---|---|
path | string | — |
uid | long | — |
pathCustom-format file path: logical asset:// or user:// as appropriate for its storage location.
uidNew numeric resource UID. Store it in a form understood by the corresponding format loader.
ErrorError.Ok after updating the UID, or a specific Error for failure or an unsupported format.