Search Results for

    Show / Hide Table of Contents

    Class BinaryAsset

    Base class for all binary assets.

    Inheritance
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    BinaryAsset
    Inherited Members
    Asset::_deleteFileOnUnload
    ScriptingObject::_gcHandle
    ScriptingObject::_id
    Asset::_isVirtual
    Asset::_loadingTask
    Asset::_loadState
    Asset::_refCount
    ScriptingObject::_type
    Asset::AddReference()
    Asset::Asset(const SpawnParams& params, const AssetInfo* info)
    ScriptingObject::CanCast(const ScriptingTypeHandle& from, const ScriptingTypeHandle& to)
    ScriptingObject::CanCast(const MClass* from, const MClass* to)
    Asset::CancelStreaming()
    ScriptingObject::Cast(ScriptingObject* obj)
    Asset::ChangeID(const Guid& newId)
    Asset::const
    Asset::CreateManaged()
    ScriptingObject::CreateManagedInternal()
    Asset::DECLARE_ENUM_7(LoadResult, Ok, Failed, MissingDataChunk, CannotLoadData, CannotLoadStorage, CannotLoadInitData, InvalidData)
    ScriptingObject::Deleted
    Asset::DeleteManaged()
    Object::DeleteObject(float timeToLive = 0.0f, bool useGameTime=false)
    Object::DeleteObjectNow()
    Asset::DEPRECATED("Use GetReferences with assets and files parameter instead")
    Asset::DestroyManaged()
    BinaryAsset
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    ScriptingObject::GetClass()
    ScriptingObject::GetID()
    ScriptingObject::GetManagedInstance()
    ScriptingObject::GetOrCreateManagedInstance()
    Asset::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
    Asset::GetReferences()
    Asset::GetReferencesCount()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Asset::GetTypeName()
    ScriptingObject::HasManagedInstance()
    Asset::InitAsVirtual()
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    Asset::IsInternalType()
    Asset::IsLoaded()
    ScriptingObject::IsRegistered()
    Asset::IsVirtual()
    Asset::LastLoadFailed()
    BinaryAsset
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Asset::OnCheckSave(const StringView& path=StringView::Empty)
    Asset::onLoad(LoadAssetTask* task)
    Asset::onLoaded()
    Asset::OnLoaded
    Asset::onLoaded_MainThread()
    Asset::OnManagedInstanceDeleted()
    Asset::OnReloading
    Asset::OnScriptingDispose()
    Asset::onUnload_MainThread()
    Asset::OnUnloaded
    ScriptingObject::RegisterObject()
    Asset::Reload()
    Asset::RemoveReference()
    Asset::Save(const StringView& path=StringView::Empty)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    ManagedScriptingObject::SetManagedInstance(MObject* instance)
    Asset::ShouldDeleteFileOnUnload()
    BinaryAsset
    Asset::startLoading()
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Asset::ToString()
    Asset::unload(bool isReloading)
    ScriptingObject::UnregisterObject()
    Asset::WaitForLoaded(double timeoutInMilliseconds=30000.0)
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    Assembly: FlaxEngine.dll
    File: Engine/Content/BinaryAsset.h
    Syntax
    public class BinaryAsset : public Asset

    Constructors

    ~BinaryAsset()

    Finalizes an instance of the BinaryAsset class.

    Declaration
    public ~BinaryAsset()

    Fields

    _dependantAssets

    Declaration
    protected Array<BinaryAsset* > _dependantAssets
    Field Value
    Array<BinaryAsset >

    _header

    Declaration
    protected AssetHeader _header
    Field Value
    AssetHeader

    _isSaving

    Declaration
    protected bool _isSaving
    Field Value
    bool

    _storageRef

    Declaration
    protected FlaxStorageReference _storageRef
    Field Value
    FlaxStorageReference

    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

    The asset storage container.

    Declaration
    public FlaxStorage* Storage
    Field Value
    FlaxStorage

    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
    Asset::createLoadingTask()

    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
    Asset::GetMemoryUsage()

    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
    Asset::GetPath()

    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
    Asset::loadAsset()

    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
    Asset::OnDeleteObject()

    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
    Asset::onRename(const StringView& newPath)

    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
    Asset::releaseStorage()

    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.

    See Also

    Asset
    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat