Class JsonAssetBase
Base class for all Json-format assets.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Content/JsonAsset.h
Syntax
public class JsonAssetBase : public Asset
Constructors
JsonAssetBase(const SpawnParams& params, const AssetInfo* info)
Initializes a new instance of the JsonAssetBase class.
Declaration
protected JsonAssetBase(const SpawnParams& params, const AssetInfo* info)
Parameters
|
SpawnParams
params
The object initialization parameters. |
|
AssetInfo
info
The asset object information. |
Fields
_isResaving
Declaration
protected bool _isResaving = false
Field Value
|
bool
|
_isVirtualDocument
Declaration
protected bool _isVirtualDocument = false
Field Value
|
bool
|
_path
Data
The data node (reference from Document or Document itself).
Declaration
public ISerializable::DeserializeStream* Data
Field Value
|
ISerializable::DeserializeStream
|
DataEngineBuild
The serialized data engine build number. Can be used to convert/upgrade data between different formats across different engine versions.
Declaration
public int32 DataEngineBuild
Field Value
|
int32
|
DataTypeName
The data type name from the header. Allows to recognize the data type.
Declaration
public String DataTypeName
Field Value
|
String
|
Document
The parsed json document.
Declaration
public ISerializable::SerializeDocument Document
Field Value
|
ISerializable::SerializeDocument
|
Methods
GetData()
GetMemoryUsage()
Gets amount of CPU memory used by this resource (in bytes). It's a rough estimation. Memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary.
Declaration
public virtual uint64 GetMemoryUsage() const override
Returns
|
uint64
|
Overrides
GetPath()
Gets the path to the asset storage file. In Editor, it reflects the actual file, in cooked Game, it fakes the Editor path to be informative for developers.
Declaration
public virtual String GetPath() const override
Returns
|
String
|
Overrides
GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
Gets the asset references. Supported only in Editor.
For some asset types (e.g. scene or prefab) it may contain invalid asset ids due to not perfect gather method, which is optimized to perform scan very quickly. Before using those ids perform simple validation via Content cache API. The result collection contains only 1-level-deep references (only direct ones) and is invalid if asset is not loaded. Also, the output data may have duplicated asset ids or even invalid ids (Guid::Empty).
Declaration
public virtual void GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files) const override
Parameters
|
Array<Guid, HeapAllocation>
assets
The output collection of the asset ids referenced by this asset. |
|
Array<String, HeapAllocation>
files
The output list of file paths referenced by this asset. Files might come from project Content folder (relative path is preserved in cooked game), or external location (copied into Content root folder of cooked game). |
Overrides
GetReferences(const StringAnsiView& json, Array<Guid, HeapAllocation>& assets)
Parses Json string to find any object references inside it. It can produce list of references to assets and/or scene objects. Supported only in Editor.
Declaration
public static void GetReferences(const StringAnsiView& json, Array<Guid, HeapAllocation>& assets)
Parameters
|
StringAnsiView
json
The Json string. |
|
Array<Guid, HeapAllocation>
assets
The output list of object IDs references by the asset (appended, not cleared). |
Init(const StringView& dataTypeName, const StringAnsiView& dataJson)
Initializes the virtual Json asset with custom data.
Can be used only for virtual assets created at runtime.
Declaration
public bool Init(const StringView& dataTypeName, const StringAnsiView& dataJson)
Parameters
|
StringView
dataTypeName
The data type name from the header. Allows to recognize the data type. |
|
StringAnsiView
dataJson
The Json with serialized data. |
Returns
|
bool
True if failed, otherwise false. |
loadAsset()
Loads asset
Declaration
protected virtual LoadResult loadAsset() override
Returns
|
LoadResult
Loading result |
Overrides
OnGetData(rapidjson_flax::StringBuffer& buffer)
Declaration
protected virtual void OnGetData(rapidjson_flax::StringBuffer& buffer) const
Parameters
|
rapidjson_flax::StringBuffer
buffer
|
onRename(const StringView& newPath)
Declaration
protected virtual void onRename(const StringView& newPath) override
Parameters
|
StringView
newPath
|
Overrides
Save(const StringView& path=StringView::Empty)
Saves this asset to the file. Supported only in Editor.
Declaration
public virtual bool Save(const StringView& path=StringView::Empty) override
Parameters
|
StringView
path
The custom asset path to use for the saving. Use empty value to save this asset to its own storage location. Can be used to duplicate asset. Must be specified when saving virtual asset. |
Returns
|
bool
True when cannot save data, otherwise false. |
Overrides
Save(JsonWriter& writer)
Saves this asset to the Json Writer buffer (both ID, Typename header and Data contents). Supported only in Editor.
Declaration
public bool Save(JsonWriter& writer) const
Parameters
|
JsonWriter
writer
The output Json Writer to write asset. |
Returns
|
bool
True if cannot save data, otherwise false. |
saveInternal(JsonWriter& writer)
Declaration
protected bool saveInternal(JsonWriter& writer) const
Parameters
|
JsonWriter
writer
|
Returns
|
bool
|
SetData(const StringView& value)
The Json data (as string).
Declaration
public void SetData(const StringView& value)
Parameters
|
StringView
value
|
unload(bool isReloading)
Unloads asset data
Declaration
protected virtual void unload(bool isReloading) override
Parameters
|
bool
isReloading
True if asset is reloading data, otherwise false. |