Search Results for

    Show / Hide Table of Contents

    Class Prefab

    Json asset that stores the collection of scene objects including actors and scripts. In general, it can serve as any grouping of scene objects (for example a level) or be used as a form of a template instantiated and reused throughout the scene.

    Inheritance
    Object
    ScriptingObject
    ManagedScriptingObject
    Asset
    JsonAssetBase
    Prefab
    Inherited Members
    Asset::_deleteFileOnUnload
    ScriptingObject::_gcHandle
    ScriptingObject::_id
    JsonAssetBase::_isResaving
    Asset::_isVirtual
    JsonAssetBase::_isVirtualDocument
    Asset::_loadingTask
    Asset::_loadState
    JsonAssetBase::_path
    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()
    JsonAssetBase::Data
    JsonAssetBase::DataEngineBuild
    JsonAssetBase::DataTypeName
    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::Document
    Prefab
    Object::Flags
    ScriptingObject::FromInterface(void* interfaceObj, const ScriptingTypeHandle& interfaceType)
    ScriptingObject::FromInterface(T* interfaceObj)
    ScriptingObject::GetClass()
    JsonAssetBase::GetData()
    ScriptingObject::GetID()
    ScriptingObject::GetManagedInstance()
    JsonAssetBase::GetMemoryUsage()
    ScriptingObject::GetOrCreateManagedInstance()
    JsonAssetBase::GetPath()
    JsonAssetBase::GetReferences(const StringAnsiView& json, Array<Guid, HeapAllocation>& assets)
    JsonAssetBase::GetReferences(Array<Guid, HeapAllocation>& assets, Array<String, HeapAllocation>& files)
    Asset::GetReferences()
    Asset::GetReferencesCount()
    ScriptingObject::GetType()
    ScriptingObject::GetTypeHandle()
    Asset::GetTypeName()
    ScriptingObject::HasManagedInstance()
    JsonAssetBase::Init(const StringView& dataTypeName, const StringAnsiView& dataJson)
    Asset::InitAsVirtual()
    ScriptingObject::Is(const ScriptingTypeHandle& type)
    ScriptingObject::Is(const MClass* type)
    ScriptingObject::Is()
    Asset::IsInternalType()
    Asset::IsLoaded()
    ScriptingObject::IsRegistered()
    Asset::IsVirtual()
    JsonAssetBase::JsonAssetBase(const SpawnParams& params, const AssetInfo* info)
    Asset::LastLoadFailed()
    Prefab
    Asset::Locker
    ManagedScriptingObject::ManagedScriptingObject(const SpawnParams& params)
    ScriptingObject::NewObject(const ScriptingTypeHandle& typeHandle)
    ScriptingObject::NewObject()
    Asset::OnCheckSave(const StringView& path=StringView::Empty)
    Asset::OnDeleteObject()
    JsonAssetBase::OnGetData(rapidjson_flax::StringBuffer& buffer)
    Asset::onLoad(LoadAssetTask* task)
    Asset::onLoaded()
    Asset::OnLoaded
    Asset::onLoaded_MainThread()
    Asset::OnManagedInstanceDeleted()
    Asset::OnReloading
    JsonAssetBase::onRename(const StringView& newPath)
    Asset::OnScriptingDispose()
    Asset::onUnload_MainThread()
    Asset::OnUnloaded
    ScriptingObject::RegisterObject()
    Asset::releaseStorage()
    Asset::Reload()
    Asset::RemoveReference()
    JsonAssetBase::Save(JsonWriter& writer)
    JsonAssetBase::Save(const StringView& path=StringView::Empty)
    JsonAssetBase::saveInternal(JsonWriter& writer)
    ScriptingObject::ScriptingObject(const SpawnParams& params)
    JsonAssetBase::SetData(const StringView& value)
    ManagedScriptingObject::SetManagedInstance(MObject* instance)
    Asset::ShouldDeleteFileOnUnload()
    Prefab
    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/Level/Prefabs/Prefab.h
    Syntax
    public class Prefab : public JsonAssetBase

    Fields

    NestedPrefabs

    The prefab assets ids contained within the prefab asset. Valid only if asset is loaded. Remember that each nested prefab can contain deeper references to the other assets.

    Declaration
    public Array<Guid> NestedPrefabs
    Field Value
    Array<Guid>

    ObjectsCache

    The objects cache maps the id of the object contained in the prefab asset (actor or script) to the default instance deserialized from prefab data. Valid only if asset is loaded and GetDefaultInstance was called.

    Declaration
    public Dictionary<Guid, SceneObject* > ObjectsCache
    Field Value
    Dictionary<Guid, SceneObject >

    ObjectsCount

    The serialized scene objects amount (actors and scripts).

    Declaration
    public int32 ObjectsCount
    Field Value
    int32

    ObjectsDataCache

    The objects data cache maps the id of the object contained in the prefab asset (actor or script) to the json data node for its data. Valid only if asset is loaded.

    Declaration
    public Dictionary<Guid, ISerializable::DeserializeStream* > ObjectsDataCache
    Field Value
    Dictionary<Guid, ISerializable::DeserializeStream >

    ObjectsHierarchyCache

    The object hierarchy cache that maps the PrefabObjectID into the list of children (identified also by PrefabObjectID). Objects without any children are not included for sake of optimization. Used for quick validation of the structure of loaded prefab instances. Valid only if asset is loaded.

    Declaration
    public Dictionary<Guid, Array<Guid>> ObjectsHierarchyCache
    Field Value
    Dictionary<Guid, Array<Guid>>

    ObjectsIds

    The objects ids contained within the prefab asset. Valid only if asset is loaded.

    Declaration
    public Array<Guid> ObjectsIds
    Field Value
    Array<Guid>

    Methods

    ApplyAll(Actor* targetActor)

    Applies the difference from the prefab object instance, saves the changes and synchronizes them with the active instances of the prefab asset.

    Applies all the changes from not only the given actor instance but all actors created within that prefab instance.

    Declaration
    public bool ApplyAll(Actor* targetActor)
    Parameters
    Actor targetActor

    The root actor of spawned prefab instance to use as modified changes sources.

    Returns
    bool

    True if failed, otherwise false.

    GetDefaultInstance()

    Requests the default prefab object instance. Deserializes the prefab objects from the asset. Skips if already done.

    Declaration
    public Actor* GetDefaultInstance()
    Returns
    Actor

    The root of the prefab object loaded from the prefab. Contains the default values. It's not added to gameplay but deserialized with postLoad and init event fired.

    GetDefaultInstance(const Guid& objectId)

    Requests the default prefab object instance. Deserializes the prefab objects from the asset. Skips if already done.

    Declaration
    public SceneObject* GetDefaultInstance(const Guid& objectId)
    Parameters
    Guid objectId

    The ID of the object to get from prefab default object. It can be one of the child-actors or any script that exists in the prefab. Methods returns root if id is empty.

    Returns
    SceneObject

    The object of the prefab loaded from the prefab. Contains the default values. It's not added to gameplay but deserialized with postLoad and init event fired.

    GetNestedObject(const Guid& objectId, Guid& outPrefabId, Guid& outObjectId)

    Gets the reference to the other nested prefab for a specific prefab object.

    Declaration
    public bool GetNestedObject(const Guid& objectId, Guid& outPrefabId, Guid& outObjectId) const
    Parameters
    Guid objectId

    The ID of the object in this prefab.

    Guid outPrefabId

    Result ID of the prefab asset referenced by the given object.

    Guid outObjectId

    Result ID of the prefab object referenced by the given object.

    Returns
    bool

    True if got valid reference, otherwise false.

    GetRootObjectId()

    Gets the root object identifier (prefab object ID). Asset must be loaded.

    Declaration
    public Guid GetRootObjectId() const
    Returns
    Guid

    loadAsset()

    Loads asset

    Declaration
    protected virtual LoadResult loadAsset() override
    Returns
    LoadResult

    Loading result

    Overrides
    JsonAssetBase::loadAsset()

    Resave()

    Resaves the prefab asset to the file by serializing default instance in the latest format and defaults.

    Declaration
    public bool Resave()
    Returns
    bool

    True if failed, otherwise false.

    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
    JsonAssetBase::unload(bool isReloading)

    See Also

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