FDataAssetStore
Loads, caches and saves data assets. Every loaded asset is rooted: the store keeps it alive until Unload, so a handle read from a reference stays valid.
- Module
- Game
- Header
#include "Game/MDataAsset.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using FMigrateFn = void (*)(uint32_t storedVersion, MDF::MdfNode& objectNode) | A class's own data version, the data-asset counterpart of an actor class's: the writer stamps _version on the Object node above 1, a loader runs migrate on an older node before any property is read and leaves a newer file's extra keys in place. |
Public functions
| Returns | Name | Description |
|---|---|---|
MDataAsset* | Load | The asset at path (a VFS path such as "Assets/Weapons/Rifle.data"), loading it on first request. |
MDataAsset* | LoadAs | Load, then require the asset to be expected or a subclass of it. |
MDataAsset* | Create | An asset made in memory, not yet saved. |
bool | Save | Writes the asset to nativePath and records it as the asset's path. |
std::string | Serialize | |
MDataAsset* | LoadFromString | |
bool | IsObjectAsset | Whether the text is an object data asset (names a data_class). |
void | RegisterClassVersion | |
void | Unload | |
void | UnloadAll | |
std::vector<MClass*> | FindClasses | Every registered concrete MDataAsset subclass, by name: what a "New Data Asset" menu offers. |
std::vector<MDataAsset*> | FindLoaded | Loaded assets of a class or its subclasses, by primary id order. |
Function details
Load
static MDataAsset* Load(const std::string& path)The asset at path (a VFS path such as "Assets/Weapons/Rifle.data"), loading it on first request. Null when the file is missing, is not an object data asset (a struct-based one reads through DataAsset) or names a class that is not registered.
LoadAs
static MDataAsset* LoadAs(const std::string& path, const MClass* expected)Load, then require the asset to be expected or a subclass of it.
Create
static MDataAsset* Create(MClass* dataClass)An asset made in memory, not yet saved.
Save
static bool Save(MDataAsset* asset, const std::string& nativePath)Writes the asset to nativePath and records it as the asset's path.
Serialize
static std::string Serialize(MDataAsset* asset)LoadFromString
static MDataAsset* LoadFromString(const std::string& text, const std::string& path)IsObjectAsset
static bool IsObjectAsset(const std::string& text)Whether the text is an object data asset (names a data_class).
RegisterClassVersion
static void RegisterClassVersion(const std::string& className, uint32_t version, FMigrateFn migrate)Unload
static void Unload(const std::string& path)UnloadAll
static void UnloadAll()FindClasses
static std::vector<MClass*> FindClasses()Every registered concrete MDataAsset subclass, by name: what a "New Data Asset" menu offers.
FindLoaded
static std::vector<MDataAsset*> FindLoaded(const MClass* base)Loaded assets of a class or its subclasses, by primary id order.