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.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public class Prefab : JsonAssetBase
Constructors
Prefab()
Methods
GetDefaultInstance()
Requests the default prefab object instance. Deserializes the prefab objects from the asset. Skips if already done.
Declaration
[Unmanaged]
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(ref Guid)
Requests the default prefab object instance. Deserializes the prefab objects from the asset. Skips if already done.
Declaration
[Unmanaged]
public SceneObject GetDefaultInstance(ref Guid objectId)
Parameters
System.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(ref Guid, out Guid, out Guid)
Gets the reference to the other nested prefab for a specific prefab object.
Declaration
[Unmanaged]
public bool GetNestedObject(ref Guid objectId, out Guid outPrefabId, out Guid outObjectId)
Parameters
System.Guid
objectId
The ID of the object in this prefab. |
System.Guid
outPrefabId
Result ID of the prefab asset referenced by the given object. |
System.Guid
outObjectId
Result ID of the prefab object referenced by the given object. |
Returns
System.Boolean
True if got valid reference, otherwise false. |
Resave()
Resaves the prefab asset to the file by serializing default instance in the latest format and defaults.
Declaration
[Unmanaged]
public bool Resave()
Returns
System.Boolean
True if failed, otherwise false. |