class
Prefab
Prefab is a saveable hierarchy of scene objects.
It can be instanced, and instances will maintain a link to the original prefab they were created from, allowing you to update them to latest version if the prefab changes. Prefabs can also be nested within each-other, as long as there are no circular dependencies. Instanced prefabs can also contain per instance modifications that will be preserved even if the prefab they were created from changes.
Public
Constructors
Prefab
Methods
~Prefab
Instantiate
Instantiates a prefab by creating an instance of the prefab's scene object hierarchy.
The returned hierarchy will be parented to the provided scene instance root.
- sceneInstance
- Scene instance into which to instantiate the prefab instance in.
Returns: Instantiated clone of the prefab's scene object hierarchy.
GetPrefabVersion
Returns a version value that gets updated every time the prefab contents update.
Can be used for detecting if a prefab instance is up to date.
AllowAsyncLoading
Returns whether or not this resource is allowed to be asynchronously loaded.
staticCreate
Creates a new prefab from the provided scene object.
If the scene object has an existing prefab link it will be broken. After the prefab is created the scene object will be automatically linked to it.
staticGetRttiStatic
Internal
Methods
GetRoot
Returns a reference to the internal prefab hierarchy.
Returned hierarchy is not instantiated and cannot be interacted with in a manner you would with normal scene objects.
GetGameObjectCollection
Returns the game object collection that owns all the game objects in the prefab.
Clone
Creates the clone of the prefab's current hierarchy but doesn't instantiate it.
- cloneOwnerCollection
- Collection into which to place the cloned scene objects. If is true this must be a different collection that the prefab's internal collection, otherwise IDs would conflict.
Returns: Clone of the prefab's scene object hierarchy.
InstantiateAsScene
Instantiates a prefab by creating an instance of the prefab's scene object hierarchy as a brand new scene instance, whose root is the prefab root.
Returns: Newly created scene instance.
ReplaceInternalHierarchy
Replaces the contents of this prefab with new contents from the provided object.
Returns a map of IDs that were remapped to new IDs within the prefab.
TickPrefabVersion
Updates the internal prefab version to a new value.
You should call this after modifying the prefab hierarchy.
RecordNestedPrefabInstanceDeltas
Updates deltas for any nested prefab instances.
Private
Methods
InstantiateInternal
Instantiates a prefab by creating an instance of the prefab's scene object hierarchy.
The returned hierarchy will be parented to world root by default, if the provided instance is non-empty. If the provided scene instance is empty, new scene instance will be created and prefab's root will be set as the scene instance's root.
- inOutSceneInstance
- Scene instance into which to instantiate the prefab instance in. If null, new scene instance will be created and output through this parameter.
Returns: Instantiated clone of the prefab's scene object hierarchy.
Initialize
Initializes all the internal data of this object.
Must be called right after construction for new objects, or after deserialization for deserialized objects. If requested, render proxy is created and queued for initialization on the render thread.
Destroy
Frees all the data held by this object.
If the object has a render proxy, the internal reference to the render proxy will be released, but the proxy will not be destroyed unless this was the last reference. If render proxy destruction does happen, it is not immediate, but rather queued for destruction on the render thread.
Fields
mRoot
mPrefabVersion
mUUID
mGameObjectCollection
Collection owning the internal hierarchy.