Class BinaryAsset
Base class for all binary assets.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Content/BinaryAsset.h
Syntax
public class BinaryAsset : public Asset
Constructors
~BinaryAsset()
Fields
_dependantAssets
Declaration
protected Array<BinaryAsset* > _dependantAssets
Field Value
Array<BinaryAsset >
|
_header
_isSaving
Declaration
protected bool _isSaving
Field Value
bool
|
_storageRef
Dependencies
Asset dependencies list used by the asset for tracking (eg. material functions used by material asset). The pair of asset ID and cached file edit time (for tracking modification).
Declaration
public Array<Pair<Guid, DateTime>> Dependencies
Field Value
Array<Pair<Guid, DateTime>>
|
Metadata
The asset metadata information. Stored in a Json format.
Declaration
public BytesContainer Metadata
Field Value
BytesContainer
|
Storage
Methods
AddDependency(BinaryAsset* asset)
Adds the dependency to the given asset.
Declaration
public void AddDependency(BinaryAsset* asset)
Parameters
BinaryAsset
asset
The asset to depend on. |
ClearDependencies()
Clears the asset dependencies list and unregisters from tracking their changes.
Declaration
public void ClearDependencies()
createLoadingTask()
Creates the loading tasks sequence (allows to inject custom tasks to asset loading logic).
Declaration
protected virtual ContentLoadTask* createLoadingTask() override
Returns
ContentLoadTask
First task to call on start loading |
Overrides
GetChunk(int32 index)
Gets the asset chunk.
Declaration
public FlaxChunk* GetChunk(int32 index) const
Parameters
int32
index
The chunk index. |
Returns
FlaxChunk
Flax Chunk object or null if is missing |
GetChunkData(int32 index, BytesContainer& data)
Gets chunk data. May fail if not data requested. See RequestChunkDataAsync.
Declaration
public void GetChunkData(int32 index, BytesContainer& data) const
Parameters
int32
index
The chunk index. |
BytesContainer
data
Result data (linked chunk data, not copied). |
GetChunkSize(int32 index)
Gets the chunk size (in bytes).
Declaration
public uint32 GetChunkSize(int32 index) const
Parameters
int32
index
The chunk index. |
Returns
uint32
Chunk size (in bytes) |
getChunksToPreload()
Gets packed chunks indices to preload before asset loading action
Declaration
protected virtual AssetChunksFlag getChunksToPreload() const
Returns
AssetChunksFlag
Chunks to load flags |
GetImportMetadata(String& path, String& username)
Returns imported file metadata.
Declaration
public void GetImportMetadata(String& path, String& username) const
Parameters
String
path
The import path. |
String
username
The import username. |
GetImportPath()
Gets the imported file path from the asset metadata (can be empty if not available).
Declaration
public String GetImportPath() const
Returns
String
|
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
GetOrCreateChunk(int32 index)
Gets or creates the asset chunk.
Declaration
public FlaxChunk* GetOrCreateChunk(int32 index) const
Parameters
int32
index
The chunk index. |
Returns
FlaxChunk
Flax Chunk object (may be null if asset storage doesn't allow to add new chunks). |
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 final override
Returns
String
|
Overrides
GetSerializedVersion()
Gets the asset serialized version.
Declaration
public virtual uint32 GetSerializedVersion() const = 0
Returns
uint32
|
HasChunk(int32 index)
Determines whether the specified chunk exists.
Declaration
public bool HasChunk(int32 index) const
Parameters
int32
index
The chunk index. |
Returns
bool
True if the specified chunk exists, otherwise false. |
HasChunkLoaded(int32 index)
Determines whether the specified chunk exists and is loaded.
Declaration
public bool HasChunkLoaded(int32 index) const
Parameters
int32
index
The chunk index. |
Returns
bool
True if the specified chunk exists and is loaded, otherwise false. |
HasDependenciesModified()
Determines whether any of the dependency assets was modified after last modification time of this asset (last file write time check).
Declaration
public bool HasDependenciesModified() const
Returns
bool
|
Init(AssetInitData& initData)
Initializes the specified asset.
Declaration
public bool Init(AssetInitData& initData)
Parameters
AssetInitData
initData
The initialize data. |
Returns
bool
True if cannot init, otherwise false |
init(AssetInitData& initData)
Initializes the specified asset.
Declaration
protected virtual bool init(AssetInitData& initData)
Parameters
AssetInitData
initData
The initialize data. |
Returns
bool
True if cannot init, otherwise false |
Init(const FlaxStorageReference& storage, AssetHeader& header)
Initializes the specified asset with asset header and storage only. Asset should be initialized later using will AssetInitData.
Declaration
public bool Init(const FlaxStorageReference& storage, AssetHeader& header)
Parameters
FlaxStorageReference
storage
The storage container. |
AssetHeader
header
The asset header. |
Returns
bool
|
InitVirtual(AssetInitData& initData)
Initializes the specified asset (as virtual).
Declaration
public bool InitVirtual(AssetInitData& initData)
Parameters
AssetInitData
initData
The initialize data. |
Returns
bool
True if cannot init, otherwise false |
load()
Load data from the chunks
Declaration
protected virtual LoadResult load() = 0
Returns
LoadResult
Loading result |
loadAsset()
Loads asset
Declaration
protected virtual LoadResult loadAsset() override
Returns
LoadResult
Loading result |
Overrides
LoadChunk(int32 chunkIndex)
Loads the chunk (synchronous, blocks current thread).
Declaration
public bool LoadChunk(int32 chunkIndex) const
Parameters
int32
chunkIndex
The chunk index to load. |
Returns
bool
True if failed, otherwise false. |
LoadChunks(AssetChunksFlag chunks)
Loads the chunks (synchronous, blocks current thread).
Declaration
public bool LoadChunks(AssetChunksFlag chunks) const
Parameters
AssetChunksFlag
chunks
The chunks to load (packed in a flag). |
Returns
bool
True if failed, otherwise false. |
OnDeleteObject()
Deletes the object. Called by the ObjectsRemovalService. Can be overriden to provide custom logic per object (cleanup, etc.).
Declaration
public virtual void OnDeleteObject() override
Overrides
OnDependencyModified(BinaryAsset* asset)
Called when one of the asset dependencies gets modified (it was saved or reloaded or reimported).
Declaration
protected virtual void OnDependencyModified(BinaryAsset* asset)
Parameters
BinaryAsset
asset
The modified asset that this asset depends on. |
onRename(const StringView& newPath)
Declaration
protected virtual void onRename(const StringView& newPath) override
Parameters
StringView
newPath
|
Overrides
Reimport()
Reimports asset from the source file.
Declaration
public void Reimport() const
ReleaseChunk(int32 index)
Releases the chunk data (if loaded).
Declaration
public void ReleaseChunk(int32 index) const
Parameters
int32
index
The chunk index. |
ReleaseChunks()
Releases all the chunks data.
Declaration
public void ReleaseChunks() const
releaseStorage()
Releases the storage file/container handle to prevent issues when renaming or moving the asset.
Declaration
protected virtual void releaseStorage() final override
Overrides
RequestChunkDataAsync(int32 index)
Requests the chunk data asynchronously (creates task that will gather chunk data or null if already here).
Declaration
public ContentLoadTask* RequestChunkDataAsync(int32 index)
Parameters
int32
index
The chunk index. |
Returns
ContentLoadTask
Task that will gather chunk data or null if already here. |
SaveAsset(AssetInitData& data, bool silentMode=false)
Saves this asset to the storage container.
Declaration
public bool SaveAsset(AssetInitData& data, bool silentMode=false) const
Parameters
AssetInitData
data
Asset data. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
Returns
bool
True if failed, otherwise false. |
SaveAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
Saves this asset to the file.
Declaration
public bool SaveAsset(const StringView& path, AssetInitData& data, bool silentMode=false) const
Parameters
StringView
path
Asset path (will be used to override the asset or create a new one). |
AssetInitData
data
Asset data. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
Returns
bool
True if failed, otherwise false. |
SaveToAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
Saves asset data to the storage container. Asset unique ID is handled by auto.
Declaration
public static bool SaveToAsset(const StringView& path, AssetInitData& data, bool silentMode=false)
Parameters
StringView
path
Asset path (will be used to override the asset or create a new one). |
AssetInitData
data
Asset data. |
bool
silentMode
In silent mode don't reload opened storage container that is using target file. |
Returns
bool
True if failed, otherwise false. |
SetChunk(int32 index, const Span<byte>& data)
Sets the chunk data (creates new chunk if is missing).
Declaration
public void SetChunk(int32 index, const Span<byte>& data)
Parameters
int32
index
The chunk index. |
Span<byte>
data
The chunk data to set. |