Class FileAvDataLoader
- Namespace
- Uralstech.AvLoader.DataLoaders
Loads avatars from on-device files.
public class FileAvDataLoader : IAvDataLoader
- Inheritance
-
objectFileAvDataLoader
- Implements
Constructors
FileAvDataLoader(string, string, string?, string?)
Creates a loader configured to load avatar data from paths to each file.
public FileAvDataLoader(string modelFilePath, string metadataFilePath, string? fullRenderFilePath = null, string? bustRenderFilePath = null)
Parameters
modelFilePathstringPath to the model.
metadataFilePathstringPath to the avatar metadata.
fullRenderFilePathstringPath to the full render of the avatar (optional).
bustRenderFilePathstringPath to the bust render of the avatar (optional).
Exceptions
- NotSupportedException
Thrown if the file extension of
modelFilePath,fullRenderFilePathorbustRenderFilePathis not supported.
FileAvDataLoader(string, AvModelFileExtension, AvImageFileExtension, AvImageFileExtension, bool, bool)
Creates a loader configured to load avatar data from the directory at basePath.
public FileAvDataLoader(string basePath, AvModelFileExtension modelFormat = AvModelFileExtension.None, AvImageFileExtension fullRenderFormat = AvImageFileExtension.None, AvImageFileExtension bustRenderFormat = AvImageFileExtension.None, bool shouldLoadFullRender = false, bool shouldLoadBustRender = false)
Parameters
basePathstringThe base directory containing the avatar and its metadata.
modelFormatAvModelFileExtensionThe expected file extension(s) of the model, leave as None to auto detect of all supported formats.
fullRenderFormatAvImageFileExtensionThe expected file extension(s) of the model's full render, leave as None to auto detect of all supported formats.
bustRenderFormatAvImageFileExtensionThe expected file extension(s) of the model's bust render, leave as None to auto detect of all supported formats.
shouldLoadFullRenderboolShould the full render be loaded?
shouldLoadBustRenderboolShould the bust render be loaded?
Remarks
basePath must contain the avatar and associated data in the following structure:
basePath/
├─ model.[supported model extension] # The avatar's model
├─ metadata.json # Metadata
├─ full.[supported image extension] # Full render of the avatar (optional)
└─ bust.[supported image extension] # Bust render of the avatar (optional)
If you want to use a different file structure, call FileAvDataLoader(string, string, string?, string?) instead.
Methods
LoadAvatarAsync(bool, CancellationToken)
Tries loading an avatar into an AvSourceData.
public Awaitable<AvSourceData?> LoadAvatarAsync(bool throwOnFail, CancellationToken token = default)
Parameters
throwOnFailboolShould this method throw errors on failures or log them as warnings and return null?
tokenCancellationToken
Returns
- Awaitable<AvSourceData>
The loaded data if successful; null on failure.
TrySearchForBustRender(string, AvImageFileExtension, out string?, out AvImageFileExtension)
Searches for a supported bust-render image file inside directory using the default bust-render file name.
public static bool TrySearchForBustRender(string directory, AvImageFileExtension searchFilter, out string? foundPath, out AvImageFileExtension foundExtension)
Parameters
directorystringThe directory to search in.
searchFilterAvImageFileExtensionThe expected image file extension(s). Use None or grouped values to search across all supported formats.
foundPathstringWhen this method returns true, contains the full path to the found image file.
foundExtensionAvImageFileExtensionWhen this method returns true, contains the detected image file extension.
Returns
TrySearchForFullRender(string, AvImageFileExtension, out string?, out AvImageFileExtension)
Searches for a supported full-render image file inside directory using the default full-render file name.
public static bool TrySearchForFullRender(string directory, AvImageFileExtension searchFilter, out string? foundPath, out AvImageFileExtension foundExtension)
Parameters
directorystringThe directory to search in.
searchFilterAvImageFileExtensionThe expected image file extension(s). Use None or grouped values to search across all supported formats.
foundPathstringWhen this method returns true, contains the full path to the found image file.
foundExtensionAvImageFileExtensionWhen this method returns true, contains the detected image file extension.
Returns
TrySearchForImageFile(string, string, AvImageFileExtension, out string?, out AvImageFileExtension)
Searches for a supported image file inside directory using a custom base file name.
public static bool TrySearchForImageFile(string directory, string fileNameWithoutExtensino, AvImageFileExtension searchFilter, out string? foundPath, out AvImageFileExtension foundExtension)
Parameters
directorystringThe directory to search in.
fileNameWithoutExtensinostringThe image file name without an extension.
searchFilterAvImageFileExtensionThe expected image file extension(s). Use None or grouped values to search across all supported formats.
foundPathstringWhen this method returns true, contains the full path to the found image file.
foundExtensionAvImageFileExtensionWhen this method returns true, contains the detected image file extension.
Returns
TrySearchForModelFile(string, string, AvModelFileExtension, out string?, out AvModelFileExtension)
Searches for a supported avatar model file inside directory using a custom base file name.
public static bool TrySearchForModelFile(string directory, string fileNameWithoutExtensino, AvModelFileExtension searchFilter, out string? foundPath, out AvModelFileExtension foundExtension)
Parameters
directorystringThe directory to search in.
fileNameWithoutExtensinostringThe model file name without an extension.
searchFilterAvModelFileExtensionThe expected model file extension(s). Use None or grouped values to search across all supported formats.
foundPathstringWhen this method returns true, contains the full path to the found model file.
foundExtensionAvModelFileExtensionWhen this method returns true, contains the detected model file extension.
Returns
TrySearchForModelFile(string, AvModelFileExtension, out string?, out AvModelFileExtension)
Searches for a supported avatar model file inside directory using the default model file name.
public static bool TrySearchForModelFile(string directory, AvModelFileExtension searchFilter, out string? foundPath, out AvModelFileExtension foundExtension)
Parameters
directorystringThe directory to search in.
searchFilterAvModelFileExtensionThe expected model file extension(s). Use None or grouped values to search across all supported formats.
foundPathstringWhen this method returns true, contains the full path to the found model file.
foundExtensionAvModelFileExtensionWhen this method returns true, contains the detected model file extension.