Search Results for

    Show / Hide Table of Contents

    Class JsonAssetBase

    Base class for all Json-format assets.

    Inheritance
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    JsonAssetBase
    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::createLoadingTask()
    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()
    JsonAssetBase
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    ScriptingObject::GetClass()
    ScriptingObject::GetID()
    ScriptingObject::GetManagedInstance()
    ScriptingObject::GetOrCreateManagedInstance()
    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()
    JsonAssetBase
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Asset::OnCheckSave(const StringView& path=StringView::Empty)
    Asset::OnDeleteObject()
    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::releaseStorage()
    Asset::Reload()
    Asset::RemoveReference()
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    ManagedScriptingObject::SetManagedInstance(MObject* instance)
    Asset::ShouldDeleteFileOnUnload()
    JsonAssetBase
    Asset::startLoading()
    ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::ToInterface(ScriptingObject* obj)
    ScriptingObject::ToManaged(const ScriptingObject* obj)
    ScriptingObject::ToNative(MObject* obj)
    Asset::ToString()
    ScriptingObject::UnregisterObject()
    Asset::WaitForLoaded(double timeoutInMilliseconds=30000.0)
    Object::~Object()
    ScriptingObject::~ScriptingObject()
    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

    Declaration
    protected String _path
    Field Value
    String

    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()

    The Json data (as string).

    Declaration
    public String GetData() 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()

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

    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
    Asset::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)

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

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

    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
    Asset::Save(const StringView& path=StringView::Empty)

    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.

    Overrides
    Asset::unload(bool isReloading)

    See Also

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